-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[vscode] support editor/linenumber/context menu #12638
[vscode] support editor/linenumber/context menu #12638
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.
I have some minor comments about the code and formatting.
When testing I noticed some odd behaviours:
- the
lineNumber
is 1 position less than what is selected - the extension might have a typo in the command registration of
sample-menu-extension.helloWorld
- in vscode this command is never available in the context-menu (as it has no title) while theia displays it
The error in definition is the missing context
in the id
:
"contributes": {
"commands": [
{
"command": "sample-menu-extension.context.helloWorld",
"title": "Sample Extension Editor LineNumber Context"
},
{
"command": "sample-menu-extension.lineGreaterThan10",
"title": "LineNumber Greater than 10!"
}
],
"menus": {
"editor/lineNumber/context": [
{
"command": "sample-menu-extension.helloWorld",
"icon" : "$(notebook-execute)"
},
{
"command": "sample-menu-extension.lineGreaterThan10",
"icon" : "$(notebook-execute)",
"when": "editorLineNumber > 10"
}
]
}
}
Thanks a lot for your review, @vince-fugnitto! I fixed the formatting issues in a first commit. I updated the examples, so the basic line number menu is now visible in theia and vscode.
|
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.
Thank you for the contribution. It does not work for me, please see the screencast. The code can be improved a bit.
protected readonly quickInputService: QuickInputService; | ||
|
||
onStart(): void { | ||
this.editorManager.onCreated(editor => this.addLineNumberContextMenu(editor)); |
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.
This won't work. If two editors are open, the context menu on the line number works, close one of the editors, and the feature stops working.
line_context_menu.mp4
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.
Each editor contribution is now disposed on its own editor disposal.
@kittaakos, thanks for your review! |
@rschnekenbu please ping me when you address the feedback and conflicts, and I'll happily re-review 👍 |
4a2b423
to
18f71da
Compare
@vince-fugnitto, thanks for taking care again of this PR! I rebased and resolved the conflicts, and I addressed the comments from you and Akos. The menu is now disposed by its own editor, so there can be several editors opened and closed, the menu contribution remains for an editor until the editor itself is disposed. |
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.
The changes look good to me, and work well as well 👍
* Adds contextual menu to line number area in text editors * map the predefined vscode entry "editor/linenumber/context" to theia Contributed on behalf of STMicroelectronics Signed-off-by: Remi Schnekenburger <[email protected]>
18f71da
to
8e804f4
Compare
All comments have been addressed, this PR can now be merged. Thanks @vince-fugnitto and @kittaakos for your help 👍 |
What it does
Adds a missing predefined entry in the menus
This enables the possibility to contribute menus to editor/linenumber/context entry as defined in vscode 1.78 (see https://code.visualstudio.com/updates/v1_78#_editorlinenumbercontext-menu)
Fixes #12560
Contributed on behalf of ST Microelectronics
How to test
Try to open a menu on any text file, no menu shall open when right-clicking a line number. An error shall also be displayed in the console when the extension is activated.
Update your
theia
repository to use this PRAny text file shall now display at least one menu on line numbers. If line selected is above 11, then a second menu shall also be displayed. This demonstrates the context key editorLineNumber is set correctly. The information displayed when selecting the action shows the current URI for the edited resource, and the line number, as expected by vscode.
The build-in github extension shall also start without displaying a comment on a missing menu entry for editor/linenumber/context.
Review checklist
Reminder for reviewers