Skip to content

Commit 435955d

Browse files
committed
Register previous ids for compatibility (microsoft#53497)
1 parent f365098 commit 435955d

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/vs/editor/contrib/wordPartOperations/wordPartOperations.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { WordCharacterClassifier } from 'vs/editor/common/controller/wordCharact
1616
import { DeleteWordCommand, MoveWordCommand } from '../wordOperations/wordOperations';
1717
import { Position } from 'vs/editor/common/core/position';
1818
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
19+
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
1920

2021
export class DeleteWordPartLeft extends DeleteWordCommand {
2122
constructor() {
@@ -90,6 +91,9 @@ export class CursorWordPartLeft extends WordPartLeftCommand {
9091
});
9192
}
9293
}
94+
// Register previous id for compatibility purposes
95+
CommandsRegistry.registerCommandAlias('cursorWordPartStartLeft', 'cursorWordPartLeft');
96+
9397
export class CursorWordPartLeftSelect extends WordPartLeftCommand {
9498
constructor() {
9599
super({
@@ -106,6 +110,8 @@ export class CursorWordPartLeftSelect extends WordPartLeftCommand {
106110
});
107111
}
108112
}
113+
// Register previous id for compatibility purposes
114+
CommandsRegistry.registerCommandAlias('cursorWordPartStartLeftSelect', 'cursorWordPartLeftSelect');
109115

110116
export class WordPartRightCommand extends MoveWordCommand {
111117
protected _move(wordSeparators: WordCharacterClassifier, model: ITextModel, position: Position, wordNavigationType: WordNavigationType): Position {

src/vs/platform/commands/common/commands.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface ICommandHandlerDescription {
4646
export interface ICommandRegistry {
4747
registerCommand(id: string, command: ICommandHandler): IDisposable;
4848
registerCommand(command: ICommand): IDisposable;
49+
registerCommandAlias(oldId: string, newId: string): IDisposable;
4950
getCommand(id: string): ICommand;
5051
getCommands(): ICommandsMap;
5152
}
@@ -99,6 +100,12 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
99100
});
100101
}
101102

103+
registerCommandAlias(oldId: string, newId: string): IDisposable {
104+
return CommandsRegistry.registerCommand(oldId, (accessor, ...args) => {
105+
accessor.get(ICommandService).executeCommand(newId, ...args);
106+
});
107+
}
108+
102109
getCommand(id: string): ICommand {
103110
const list = this._commands.get(id);
104111
if (!list || list.isEmpty()) {

0 commit comments

Comments
 (0)