-
Notifications
You must be signed in to change notification settings - Fork 29.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
editor: introduce anchor selection #97912
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I just left some small tweaks suggestions.
src/vs/editor/editor.all.ts
Outdated
@@ -45,6 +45,7 @@ import 'vs/editor/contrib/viewportSemanticTokens/viewportSemanticTokens'; | |||
import 'vs/editor/contrib/wordHighlighter/wordHighlighter'; | |||
import 'vs/editor/contrib/wordOperations/wordOperations'; | |||
import 'vs/editor/contrib/wordPartOperations/wordPartOperations'; | |||
import 'vs/editor/contrib/anchorSelect/anchorSelect'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: this list was alphabetically sorted.
precondition: SelectionAnchorSet, | ||
kbOpts: { | ||
kbExpr: EditorContextKeys.editorTextFocus, | ||
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_K), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should look if cmd+k cmd+k
is available. You can check the availability across OSes here -- https://github.com/microsoft/vscode-docs/tree/master/build/keybindings
precondition: undefined, | ||
kbOpts: { | ||
kbExpr: EditorContextKeys.editorTextFocus, | ||
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_B), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should look if cmd+k cmd+b
is available. You can check the availability across OSes here -- https://github.com/microsoft/vscode-docs/tree/master/build/keybindings
className: 'selection-anchor' | ||
} | ||
}]); | ||
this.decorationId = newDecorationId.length === 1 ? newDecorationId[0] : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is safe to use newDecorationIds[0]
. The length will always be 1 because 1 new decoration is passed in above.
private editor: ICodeEditor, | ||
@IContextKeyService contextKeyService: IContextKeyService | ||
) { | ||
this.selectionAnchorSetContextKey = SelectionAnchorSet.bindTo(contextKeyService); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should also listen to editor.onDidChangeModel
and reset the context key if the editor gets a new model set.
@alexdima thanks a lot for the review. Tackled all comments. Merging. |
fixes #95894
This PR introduces the following commands:
Cmd + K, B
keybindingCmd + K, K
keybdiningEsc
keybindingAs for changning default keybindings I woud like to have this in insiders so users try it out and then we can change it.
Potential follow up work:
width
with!important
.@alexdima let me know what you think