提交 f0cd2ce0 编写于 作者: I isidor

tacke review comments

上级 37a7ec0e
...@@ -15,6 +15,7 @@ import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/cont ...@@ -15,6 +15,7 @@ import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/cont
import { IEditorContribution } from 'vs/editor/common/editorCommon'; import { IEditorContribution } from 'vs/editor/common/editorCommon';
import { TrackedRangeStickiness } from 'vs/editor/common/model'; import { TrackedRangeStickiness } from 'vs/editor/common/model';
import { MarkdownString } from 'vs/base/common/htmlContent'; import { MarkdownString } from 'vs/base/common/htmlContent';
import { IDisposable } from 'vs/base/common/lifecycle';
export const SelectionAnchorSet = new RawContextKey('selectionAnchorSet', false); export const SelectionAnchorSet = new RawContextKey('selectionAnchorSet', false);
...@@ -28,12 +29,14 @@ class SelectionAnchorController implements IEditorContribution { ...@@ -28,12 +29,14 @@ class SelectionAnchorController implements IEditorContribution {
private decorationId: string | undefined; private decorationId: string | undefined;
private selectionAnchorSetContextKey: IContextKey<boolean>; private selectionAnchorSetContextKey: IContextKey<boolean>;
private modelChangeListener: IDisposable;
constructor( constructor(
private editor: ICodeEditor, private editor: ICodeEditor,
@IContextKeyService contextKeyService: IContextKeyService @IContextKeyService contextKeyService: IContextKeyService
) { ) {
this.selectionAnchorSetContextKey = SelectionAnchorSet.bindTo(contextKeyService); this.selectionAnchorSetContextKey = SelectionAnchorSet.bindTo(contextKeyService);
this.modelChangeListener = editor.onDidChangeModel(() => this.selectionAnchorSetContextKey.reset());
} }
setSelectionAnchor(): void { setSelectionAnchor(): void {
...@@ -48,7 +51,7 @@ class SelectionAnchorController implements IEditorContribution { ...@@ -48,7 +51,7 @@ class SelectionAnchorController implements IEditorContribution {
className: 'selection-anchor' className: 'selection-anchor'
} }
}]); }]);
this.decorationId = newDecorationId.length === 1 ? newDecorationId[0] : undefined; this.decorationId = newDecorationId[0];
this.selectionAnchorSetContextKey.set(!!this.decorationId); this.selectionAnchorSetContextKey.set(!!this.decorationId);
} }
} }
...@@ -83,6 +86,7 @@ class SelectionAnchorController implements IEditorContribution { ...@@ -83,6 +86,7 @@ class SelectionAnchorController implements IEditorContribution {
dispose(): void { dispose(): void {
this.cancelSelectionAnchor(); this.cancelSelectionAnchor();
this.modelChangeListener.dispose();
} }
} }
...@@ -95,7 +99,7 @@ class SetSelectionAnchor extends EditorAction { ...@@ -95,7 +99,7 @@ class SetSelectionAnchor extends EditorAction {
precondition: undefined, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_B), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_B),
weight: KeybindingWeight.EditorContrib weight: KeybindingWeight.EditorContrib
} }
}); });
...@@ -132,7 +136,7 @@ class SelectFromAnchorToCursor extends EditorAction { ...@@ -132,7 +136,7 @@ class SelectFromAnchorToCursor extends EditorAction {
precondition: SelectionAnchorSet, precondition: SelectionAnchorSet,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_K), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K),
weight: KeybindingWeight.EditorContrib weight: KeybindingWeight.EditorContrib
} }
}); });
......
...@@ -7,6 +7,7 @@ import 'vs/editor/browser/controller/coreCommands'; ...@@ -7,6 +7,7 @@ import 'vs/editor/browser/controller/coreCommands';
import 'vs/editor/browser/widget/codeEditorWidget'; import 'vs/editor/browser/widget/codeEditorWidget';
import 'vs/editor/browser/widget/diffEditorWidget'; import 'vs/editor/browser/widget/diffEditorWidget';
import 'vs/editor/browser/widget/diffNavigator'; import 'vs/editor/browser/widget/diffNavigator';
import 'vs/editor/contrib/anchorSelect/anchorSelect';
import 'vs/editor/contrib/bracketMatching/bracketMatching'; import 'vs/editor/contrib/bracketMatching/bracketMatching';
import 'vs/editor/contrib/caretOperations/caretOperations'; import 'vs/editor/contrib/caretOperations/caretOperations';
import 'vs/editor/contrib/caretOperations/transpose'; import 'vs/editor/contrib/caretOperations/transpose';
...@@ -45,7 +46,6 @@ import 'vs/editor/contrib/viewportSemanticTokens/viewportSemanticTokens'; ...@@ -45,7 +46,6 @@ import 'vs/editor/contrib/viewportSemanticTokens/viewportSemanticTokens';
import 'vs/editor/contrib/wordHighlighter/wordHighlighter'; import 'vs/editor/contrib/wordHighlighter/wordHighlighter';
import 'vs/editor/contrib/wordOperations/wordOperations'; import 'vs/editor/contrib/wordOperations/wordOperations';
import 'vs/editor/contrib/wordPartOperations/wordPartOperations'; import 'vs/editor/contrib/wordPartOperations/wordPartOperations';
import 'vs/editor/contrib/anchorSelect/anchorSelect';
// Load up these strings even in VSCode, even if they are not used // Load up these strings even in VSCode, even if they are not used
// in order to get them translated // in order to get them translated
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册