提交 6b7eabb7 编写于 作者: J Johannes Rieken

honor language overrides for config.editor.suggest.insertMode-setting

上级 52051132
...@@ -26,6 +26,7 @@ export const Context = { ...@@ -26,6 +26,7 @@ export const Context = {
MakesTextEdit: new RawContextKey('suggestionMakesTextEdit', true), MakesTextEdit: new RawContextKey('suggestionMakesTextEdit', true),
AcceptSuggestionsOnEnter: new RawContextKey<boolean>('acceptSuggestionOnEnter', true), AcceptSuggestionsOnEnter: new RawContextKey<boolean>('acceptSuggestionOnEnter', true),
HasInsertAndReplaceRange: new RawContextKey('suggestionHasInsertAndReplaceRange', false), HasInsertAndReplaceRange: new RawContextKey('suggestionHasInsertAndReplaceRange', false),
InsertMode: new RawContextKey<'insert' | 'replace'>('suggestionInsertMode', undefined),
CanResolve: new RawContextKey('suggestionCanResolve', false), CanResolve: new RawContextKey('suggestionCanResolve', false),
}; };
......
...@@ -124,6 +124,11 @@ export class SuggestController implements IEditorContribution { ...@@ -124,6 +124,11 @@ export class SuggestController implements IEditorContribution {
this.editor = editor; this.editor = editor;
this.model = _instantiationService.createInstance(SuggestModel, this.editor,); this.model = _instantiationService.createInstance(SuggestModel, this.editor,);
// context key: update insert/replace mode
const ctxInsertMode = SuggestContext.InsertMode.bindTo(_contextKeyService);
ctxInsertMode.set(editor.getOption(EditorOption.suggest).insertMode);
this.model.onDidTrigger(() => ctxInsertMode.set(editor.getOption(EditorOption.suggest).insertMode));
this.widget = this._toDispose.add(new IdleValue(() => { this.widget = this._toDispose.add(new IdleValue(() => {
const widget = this._instantiationService.createInstance(SuggestWidget, this.editor); const widget = this._instantiationService.createInstance(SuggestWidget, this.editor);
...@@ -654,13 +659,13 @@ MenuRegistry.appendMenuItem(suggestWidgetStatusbarMenu, { ...@@ -654,13 +659,13 @@ MenuRegistry.appendMenuItem(suggestWidgetStatusbarMenu, {
command: { id: 'acceptSelectedSuggestion', title: nls.localize('accept.insert', "Insert") }, command: { id: 'acceptSelectedSuggestion', title: nls.localize('accept.insert', "Insert") },
group: 'left', group: 'left',
order: 1, order: 1,
when: ContextKeyExpr.and(SuggestContext.HasInsertAndReplaceRange, ContextKeyExpr.equals('config.editor.suggest.insertMode', 'insert')) when: ContextKeyExpr.and(SuggestContext.HasInsertAndReplaceRange, SuggestContext.InsertMode.isEqualTo('insert'))
}); });
MenuRegistry.appendMenuItem(suggestWidgetStatusbarMenu, { MenuRegistry.appendMenuItem(suggestWidgetStatusbarMenu, {
command: { id: 'acceptSelectedSuggestion', title: nls.localize('accept.replace', "Replace") }, command: { id: 'acceptSelectedSuggestion', title: nls.localize('accept.replace', "Replace") },
group: 'left', group: 'left',
order: 1, order: 1,
when: ContextKeyExpr.and(SuggestContext.HasInsertAndReplaceRange, ContextKeyExpr.equals('config.editor.suggest.insertMode', 'replace')) when: ContextKeyExpr.and(SuggestContext.HasInsertAndReplaceRange, SuggestContext.InsertMode.isEqualTo('replace'))
}); });
registerEditorCommand(new SuggestCommand({ registerEditorCommand(new SuggestCommand({
...@@ -679,13 +684,13 @@ registerEditorCommand(new SuggestCommand({ ...@@ -679,13 +684,13 @@ registerEditorCommand(new SuggestCommand({
menuId: suggestWidgetStatusbarMenu, menuId: suggestWidgetStatusbarMenu,
group: 'left', group: 'left',
order: 2, order: 2,
when: ContextKeyExpr.and(SuggestContext.HasInsertAndReplaceRange, ContextKeyExpr.equals('config.editor.suggest.insertMode', 'insert')), when: ContextKeyExpr.and(SuggestContext.HasInsertAndReplaceRange, SuggestContext.InsertMode.isEqualTo('insert')),
title: nls.localize('accept.replace', "Replace") title: nls.localize('accept.replace', "Replace")
}, { }, {
menuId: suggestWidgetStatusbarMenu, menuId: suggestWidgetStatusbarMenu,
group: 'left', group: 'left',
order: 2, order: 2,
when: ContextKeyExpr.and(SuggestContext.HasInsertAndReplaceRange, ContextKeyExpr.equals('config.editor.suggest.insertMode', 'replace')), when: ContextKeyExpr.and(SuggestContext.HasInsertAndReplaceRange, SuggestContext.InsertMode.isEqualTo('replace')),
title: nls.localize('accept.insert', "Insert") title: nls.localize('accept.insert', "Insert")
}] }]
})); }));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册