Skip to content

Commit 5204e81

Browse files
authored
feat(run-config): 运行配置文件夹、列表排序与复制任意配置(runConfig.arrange / runConfig.copyConfiguration) (#91)
- 配置新增 folder 字段(对应 IDEA 的 folderName),保存在配置本身,项目层配置的文件夹随项目共享。 - 本机的列表顺序和是否按名称排序保存在 local.yaml 的 arrangement 下;resolve 按显示顺序返回配置并带 sortAlphabetically,格式错误时报 invalidArrangement 诊断并忽略。 - runConfig.arrange 移动配置到文件夹(写到定义它的层,生成配置写稀疏覆盖)、保存手动顺序和排序开关。 - runConfig.copyConfiguration 复制任意配置;复制生成的构建提供者运行时同时把原配置完整保存到本地层,避免副本顶替原配置。
1 parent 16176c1 commit 5204e81

14 files changed

Lines changed: 847 additions & 0 deletions

File tree

‎rust/contracts/run-configuration-v2.schema.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
2121
},
2222
"additionalProperties": true
2323
},
24+
"arrangement": {
25+
"type": "object",
26+
"description": "Machine-local order of the run configuration list. Stored only in the local layer; omitted means sorted by name.",
27+
"properties": {
28+
"sortAlphabetically": { "type": "boolean" },
29+
"order": {
30+
"type": "array", "maxItems": 4096, "uniqueItems": true,
31+
"items": { "type": "string", "minLength": 1, "maxLength": 4096 }
32+
}
33+
},
34+
"additionalProperties": false
35+
},
2436
"configurations": {
2537
"type": "array",
2638
"items": { "$ref": "#/$defs/configuration" }
@@ -181,6 +193,11 @@
181193
"properties": {
182194
"id": { "type": "string", "minLength": 1 },
183195
"name": { "type": "string", "minLength": 1 },
196+
"folder": {
197+
"type": "string", "minLength": 1, "maxLength": 256,
198+
"pattern": "^[^\\s\\p{Cc}](?:[^\\p{Cc}]*[^\\s\\p{Cc}])?$",
199+
"description": "Folder the configuration is listed in within its kind; display only."
200+
},
184201
"provider": {
185202
"type": "string",
186203
"pattern": "^[a-z][a-z0-9-]*\\.[a-z][a-z0-9-]*$"

‎rust/contracts/rust-core-api.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,8 @@ or removing a command fails until the table changes in the same commit.
717717
| `runConfig.editorForm` | Describe the editor fields and current values of a built-in run configuration |
718718
| `runConfig.saveConfiguration` | Validate an editor form's values and return field errors or the file changes that save it |
719719
| `runConfig.deleteConfiguration` | Return the file changes that delete a saved user configuration |
720+
| `runConfig.copyConfiguration` | Return the file changes that save a copy of any configuration under a new name |
721+
| `runConfig.arrange` | Return the file changes that move configurations between folders and save the list order |
720722
| `runConfig.beforeLaunch` | Expand the built-in process runs a configuration starts first, and say whether the user must confirm them |
721723
| `runConfig.createLaunchPlan` | Project one effective configuration into a platform-neutral Run or Debug plan |
722724
| `runConfig.providerLaunchInputs` | Resolve user choices for a provider-owned launch |
@@ -3965,6 +3967,47 @@ extension namespaces the editor does not show are kept.
39653967
returns `{changes}` that remove the saved `user:` configuration from every layer.
39663968
Generated entries cannot be deleted.
39673969

3970+
`runConfig.copyConfiguration` accepts `{root, configurationId, name, plugins?}`
3971+
and replies `{id, changes}`: the copy's new `user:` ID and the changes that
3972+
save it. The copy is the resolved configuration with every saved choice, its
3973+
folder included, under the new ID and `name` (trimmed, 1 to 256 bytes). It is
3974+
saved in the project layer when the original is a user configuration defined
3975+
there without a local override, and in the local layer otherwise, so local
3976+
choices never reach the team. A saved `build.provider` run supersedes the
3977+
generated run with the same selector, so copying a generated one also saves the
3978+
original whole in the local layer under its own ID; both stay listed, and the
3979+
original stops following later name changes of the build model.
3980+
3981+
#### Folders and order
3982+
3983+
A configuration may name a `folder`, the folder it is listed in within its
3984+
kind (IntelliJ IDEA's `folderName`): 1 to 256 bytes, without surrounding
3985+
whitespace or control characters. A folder is display metadata saved in the
3986+
configuration, so a project configuration carries its folder to the team, and
3987+
a local entry `{id, folder}` overrides it like any other key; launching
3988+
ignores it. An invalid folder makes the configuration unavailable
3989+
(`invalidConfiguration`).
3990+
3991+
The order of the list and whether it is sorted by name are this machine's
3992+
choice, saved only in the local Lithe document under `arrangement:
3993+
{sortAlphabetically?: boolean, order?: string[]}`. The default sorts by name,
3994+
ignoring case. `runConfig.resolve` returns the configurations in the order the
3995+
list shows them and adds `sortAlphabetically`: by name when sorted, otherwise in
3996+
the saved `order`, with the configurations it does not name after it by name;
3997+
IDs that no longer resolve are skipped. A malformed `arrangement` is ignored
3998+
and reported as the `invalidArrangement` diagnostic.
3999+
4000+
`runConfig.arrange` accepts `{root, folders?, order?, sortAlphabetically?,
4001+
plugins?}` and returns `{changes}`. `folders` maps configuration IDs to the
4002+
folder each moves to, or `null` to take it out of its folder; each ID must
4003+
resolve. The folder is written to the layer that defines the configuration:
4004+
the project layer for a configuration saved there, otherwise the local layer,
4005+
where a generated configuration gets a sparse `{id, folder}` entry, and the
4006+
other layer's folder for it is removed. `order` replaces the whole saved order
4007+
(at most 4,096 IDs, repeats dropped) and `sortAlphabetically` the sort choice;
4008+
an omitted field keeps the saved value, and saving the defaults removes
4009+
`arrangement`. Nothing to change returns no changes.
4010+
39684011
#### Steps before launch
39694012

39704013
A configuration of any provider may name `beforeLaunch`, an ordered list of at

‎rust/crates/core/src/protocol/command.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,10 @@ pub enum RunConfigCommand {
744744
SaveConfiguration,
745745
/// Removes a user-authored run configuration (`runConfig.deleteConfiguration`).
746746
DeleteConfiguration,
747+
/// Saves a copy of a configuration under a new name (`runConfig.copyConfiguration`).
748+
CopyConfiguration,
749+
/// Moves configurations between folders and saves the list order (`runConfig.arrange`).
750+
Arrange,
747751
/// Expands the steps run before a configuration starts (`runConfig.beforeLaunch`).
748752
BeforeLaunch,
749753
/// Produces the process plan for one configuration (`runConfig.createLaunchPlan`).
@@ -1440,6 +1444,10 @@ impl CoreCommand {
14401444
"runConfig.deleteConfiguration" => {
14411445
Some(Self::RunConfig(RunConfigCommand::DeleteConfiguration))
14421446
}
1447+
"runConfig.copyConfiguration" => {
1448+
Some(Self::RunConfig(RunConfigCommand::CopyConfiguration))
1449+
}
1450+
"runConfig.arrange" => Some(Self::RunConfig(RunConfigCommand::Arrange)),
14431451
"runConfig.beforeLaunch" => Some(Self::RunConfig(RunConfigCommand::BeforeLaunch)),
14441452
"runConfig.createLaunchPlan" => {
14451453
Some(Self::RunConfig(RunConfigCommand::CreateLaunchPlan))

‎rust/crates/core/src/runtime/dispatcher/run_config.rs‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,36 @@ pub(super) fn dispatch(
247247
Err(error) => CoreResponse::failure(id, error),
248248
}
249249
}
250+
RunConfigCommand::CopyConfiguration => {
251+
match serde_json::from_value::<crate::execution::CopyConfigurationRequest>(payload)
252+
.map_err(|error| {
253+
CoreError::new(
254+
ErrorCode::InvalidRequest,
255+
"Invalid run configuration copy request",
256+
)
257+
.with_details(error.to_string())
258+
})
259+
.and_then(crate::execution::copy_configuration)
260+
{
261+
Ok(data) => CoreResponse::success(id, data),
262+
Err(error) => CoreResponse::failure(id, error),
263+
}
264+
}
265+
RunConfigCommand::Arrange => {
266+
match serde_json::from_value::<crate::execution::ArrangeRequest>(payload)
267+
.map_err(|error| {
268+
CoreError::new(
269+
ErrorCode::InvalidRequest,
270+
"Invalid run configuration arrange request",
271+
)
272+
.with_details(error.to_string())
273+
})
274+
.and_then(crate::execution::arrange)
275+
{
276+
Ok(data) => CoreResponse::success(id, data),
277+
Err(error) => CoreResponse::failure(id, error),
278+
}
279+
}
250280
RunConfigCommand::ProviderLaunchInputs => {
251281
match serde_json::from_value::<crate::execution::ProviderLaunchInputsRequest>(payload)
252282
.map_err(|error| {

‎rust/crates/core/src/tests/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ mod remote_sessions;
6161
mod request_events;
6262
mod row_selection;
6363
mod run_configuration;
64+
mod run_configuration_arrangement;
6465
pub(crate) mod support;
6566
mod toolchain_definitions;
6667
mod toolchain_pins;

0 commit comments

Comments
 (0)