Skip to content

Commit dba2fd2

Browse files
authored
fix(settings): preserve public ID field names in source editor bindings (#58)
* fix(settings): preserve public ID spellings in source editor bindings * docs(settings): record canonical source binding field repair
1 parent 7b92677 commit dba2fd2

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎rust/crates/plugin-model/src/settings.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,11 @@ pub struct SourceEditorDeclaration {
145145
pub edit_function: String,
146146
/// Optional declared build system whose native tool and stored options accompany reads.
147147
#[serde(default, skip_serializing_if = "Option::is_none")]
148+
#[serde(rename = "buildSystemID")]
148149
pub build_system_id: Option<String>,
149150
/// Optional declared language server made ready before a source query.
150151
#[serde(default, skip_serializing_if = "Option::is_none")]
152+
#[serde(rename = "languageID")]
151153
pub language_id: Option<String>,
152154
}
153155

‎rust/crates/plugin-model/src/settings/sources/tests.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,13 @@ fn absent_boolean_values_expose_inheritance_and_unknown_effective_values() {
164164
json!({"kind":"unknown","inherited":true})
165165
);
166166
}
167+
168+
#[test]
169+
fn source_editor_bindings_follow_the_public_id_field_spelling() {
170+
let value = json!({"editFunction":"compiler.prepare","buildSystemID":"fictional","languageID":"fictional"});
171+
let declaration: crate::settings::SourceEditorDeclaration =
172+
serde_json::from_value(value.clone()).unwrap();
173+
assert_eq!(declaration.build_system_id.as_deref(), Some("fictional"));
174+
assert_eq!(declaration.language_id.as_deref(), Some("fictional"));
175+
assert_eq!(serde_json::to_value(declaration).unwrap(), value);
176+
}

‎shared/plugins/contract/v1/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ Snapshot fields (unknown fields are rejected):
644644
| `groups` | 1–32 ordered `{id,title,layout,rowTitle?}` sections. `layout` is `form` or `table`; table rows use source titles in the first column and their fields as value columns. |
645645
| `sources` | At most 1024 `{id,group,title,path,revision,writable,fields}` bindings. `path` is normalized, workspace-relative, slash-separated, at most 4096 bytes and contains no empty/dot/parent components, drive letters or backslashes. Duplicate IDs or paths are rejected. Native adapters must additionally reject native file aliases and any installation resource. |
646646
| `revision` | `missing`, or `sha256:` followed by 64 lowercase hexadecimal digits covering the exact source bytes. Reading a missing source does not create it. |
647-
| `fields` | 1–32 `{id,title,description?,kind,value,effectiveValue,inheritedValue?,effectiveSource,options?}` records per source. IDs are opaque ASCII identifiers of at most 128 bytes; labels are nonblank and at most 256 bytes, descriptions at most 2048 bytes. Only explicitly non-sensitive fields may be projected. |
647+
| `fields` | 1–32 `{id,title,description?,kind,value,effectiveValue,inheritedValue?,effectiveSource,options?}` records per source. IDs are opaque identifiers using only lowercase ASCII letters, digits and hyphens, at most 128 bytes; labels are nonblank and at most 256 bytes, descriptions at most 2048 bytes. Only explicitly non-sensitive fields may be projected. |
648648
| Field values | `value:null` means absent/inherited. `effectiveValue` comes from the upstream tool and may also be null if there is no value. `inheritedValue` is the upstream value after removing a local override; omit it or use null when unknown. `effectiveSource` is a localized origin label of at most 1024 bytes. |
649649
| Field kinds | `enum` with 1–64 distinct `{value,title}` options; `boolean`; `text` up to 8192 bytes; `stringList` or `fileList` with at most 256 nonblank strings, each at most 4096 bytes. Non-enumeration fields omit options. `fileList` adds the host's file picker; list editing uses one item per line, preserving spaces and platform path spelling. |
650650

‎shared/plugins/reference/protocol-changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137

138138
| PR | 修改人 | API 编号 | 协议 / 能力 | 改了什么 |
139139
| --- | --- | --- | --- | --- |
140+
| [#58](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/58) | [@1lck](https://github.com/1lck) | API-19 | `sourceSettings` 0 内修正 | 修正来源编辑器绑定的 serde 名称,使 `buildSystemID`、`languageID` 与公开 schema、动作计划和桌面桥接一致;往返回归覆盖读取与规范序列化。明确来源字段 ID 只允许小写 ASCII 字母、数字和连字符。未新增宿主方法。 |
140141
| [#57](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/57) | [@1lck](https://github.com/1lck) | API-19、API-29 | **`sourceSettings` 0**;`buildSystems` 0 内补充 | 原生配置来源编辑:同插件独立读取/暂存函数、编译器页、上游语言/构建上下文、实际值与移除覆盖后的继承值、严格限额、显式保存及 SHA-256 收据。Core 新增 sourceState/sourceEdit/sourceReceipt 命令,原文不跨协议。构建运行时计划返回明确候选与 pathVariable,由原生宿主先验证运行时再启动构建工具;未新增宿主 RPC 方法或通知。 |
141142
| [#56](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/56) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-30 | `debugAdapters` 0 内的补充 | `targetBindings.cwd` 除了 `target.workingDirectory`,也可以绑到 `target.directory`(源文件所在目录)。调试引擎在 launch 参数缺 `cwd` 时会填工作区根目录;Go 插件绑定 `cwd` ← `target.directory` 后,被调程序在包目录运行,按包目录写的相对路径能读到。其他值以 `plugin.manifest.invalid`(字段 `targetBindings.cwd`)拒绝;目标路径是裸文件名、取不出目录时以 `debug.target.invalid`(字段 `target.path`)拒绝。只是可选取值,不需要新能力版本。 |
142143
| [#55](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/55) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-30 | `debugAdapters` 0 内的补充 | `targetBindings` 新增 `adapterArguments`:最多 8 个只有这个适配器才有的 DAP 参数,`{"<参数路径>": "<事实>"}`,路径和 `connection` 的目标一样用点分隔、最多 4 段,事实只能是 `target.path`、`target.directory` 或 `target.workingDirectory`,和其他绑定一样只在没有值时填入。`env.<变量名>` 往环境里加一个变量,`arguments` 和 `env` 绑定给的变量都保留。例如 Delve 在 `dlvCwd` 里编译程序,不在宿主给它的工作目录(工作区根目录)里编译,`go build` 又从 `PWD` 读当前目录;Go 插件绑定 `dlvCwd` 和 `env.PWD` ← `target.directory` 后,工作区根目录没有 `go.mod`、一个工作区放了多个模块、路径经过符号链接时都能调试。路径不能从 `program`、`processId`、`cwd`、`args`、`env` 本身、`noDebug`、`__` 开头的名字开始,路径之间、路径和 `connection` 的目标之间不能重叠,也不能落在 `arguments` 已有的值上或它的下面,违反时以 `plugin.manifest.invalid`(字段 `targetBindings.adapterArguments[.<参数路径>]`)拒绝;目标缺少事实时以 `debug.target.invalid`(字段 `target.path` 或 `target.workingDirectory`)拒绝。只是可选字段,不需要新能力版本。 |

0 commit comments

Comments
 (0)