File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,6 +88,20 @@ func newExporterWithEditorType(
8888 }
8989}
9090
91+ // Export (GenerateEditorConfig) generates VSCode keybindings from the keymap setting.
92+ //
93+ // Handling Existing Configurations:
94+ // It reads the existing VSCode configuration (if provided via opts.ExistingConfig) to identify
95+ // "unmanaged" keybindings—those not maintained by OneKeymap. These are preserved to support
96+ // a non-destructive export/update process.
97+ //
98+ // Conflict Resolution:
99+ // - Managed keybindings (generated from KeymapSetting) take precedence over conflicting
100+ // unmanaged keybindings from the existing configuration.
101+ // - If a keybinding in the existing configuration uses the same key combination as a
102+ // managed one, the managed one overwrites it.
103+ // - The final list is re-ordered to respect the command order of the existing configuration,
104+ // preserving the user's preferred organization where possible.
91105func (e * vscodeLikeExporter ) Export (
92106 _ context.Context ,
93107 destination io.Writer ,
Original file line number Diff line number Diff line change @@ -45,7 +45,14 @@ func newImporterWithEditorType(
4545 }
4646}
4747
48- // Import reads a VSCode keybindings.json file and converts it to a universal KeymapSetting.
48+ // Import (AnalyzeEditorConfig) reads a VSCode keybindings.json file and converts it to a universal KeymapSetting.
49+ //
50+ // Handling Existing Configurations:
51+ // It parses the VSCode JSON configuration from the source, handling comments and trailing commas.
52+ //
53+ // Conflict Resolution:
54+ // - Unknown commands or unparsable keys are skipped and tracked in the validation report.
55+ // - Duplicate actions resulting from the import are deduplicated to ensure a clean result.
4956func (i * vscodeLikeImporter ) Import (
5057 ctx context.Context ,
5158 source io.Reader ,
Original file line number Diff line number Diff line change @@ -13,7 +13,17 @@ import (
1313// into an editor-specific format.
1414type Exporter interface {
1515 // Export converts a KeymapSetting and writes it to a destination stream.
16- // It returns a report detailing any issues encountered during the conversion.
16+ //
17+ // Handling Existing Configurations:
18+ // It reads existing configuration from the input stream (if provided via opts.OriginalConfig)
19+ // to identify user-defined or unmanaged keybindings that should be preserved.
20+ //
21+ // Conflict Resolution:
22+ // - Managed keybindings (generated from KeymapSetting) take precedence over conflicting
23+ // unmanaged keybindings from the existing configuration.
24+ // - The final output attempts to respect the structure or order of the existing configuration
25+ // where applicable.
26+ // - A report is returned detailing the changes (diff) and any issues encountered.
1727 Export (
1828 ctx context.Context ,
1929 destination io.Writer ,
Original file line number Diff line number Diff line change @@ -12,8 +12,16 @@ import (
1212// Importer defines the interface for the import service, which handles the
1313// conversion of editor-specific keymaps into the universal format.
1414type Importer interface {
15- // Import converts keymaps from a source stream. It returns the converted
16- // settings and a report detailing any conflicts or unmapped actions.
15+ // Import (corresponding to AnalyzeEditorConfig logic) converts keymaps from a source stream.
16+ //
17+ // Handling Existing Configurations:
18+ // It reads configuration from the input stream (e.g., editor specific config like keybindings.json)
19+ // and analyzes it to map keybindings to the universal format.
20+ //
21+ // Conflict Resolution:
22+ // - Conflicts during conversion (e.g., multiple keybindings mapping to the same action)
23+ // are resolved by the implementation, typically by deduplicating actions.
24+ // - Any unmapped actions or ambiguities are reported in the ImportResult.
1725 Import (ctx context.Context , opts ImportOptions ) (* ImportResult , error )
1826}
1927
You can’t perform that action at this time.
0 commit comments