Closed arnoudplantinga closed 3 years ago
I will check but it might be harder than it seems. AFAIR the intercepting the caret location change is problematic. Yes VSCode UI model is extremely limited. At least it was when CodeMap was developed. But even standard thing like a custom tooltip over a treeview item is still impossible with VSCode.
As I was afraid VSCode just does not have an event that can be used by the extensions to detect the caret position change: https://code.visualstudio.com/api/references/vscode-api.
I will still keep this issue open so when/if VSCode gains the required event interface the requested feature will be implemented.
I wanted to request the same feature, too bad it's not yet possible.
Maybe a work around could be to use markers in the scroll bar of the editor for each codemap title (like the search or the debug do), with maybe a hover popup to know which marker correspond to which title...
Getting the code from the caret position is not a problem. It can be done even easier than analyzing the scrollbar.
The problem is that VSCode API does not have an event for caret position change. Thus it's not possible to detect when a new treeview node needs to be selected.
But... it can be done manually. Thus I have just released the v1.13.0 that has a command for revealing the tree view node that corresponds to the code at the current caret position in the active document.
The command can be executed either via Alt+L or a button at the top of the CodeMap view:
Hello @oleg-shilo ,
I found a solution so that I no longer need to use the button.
Just use the event vscode.window.onDidChangeTextEditorSelection
.
Whenever the course is moved, this event is triggered.
@AlencarGabriel, how did you use this event? Which file did you edit? Thanks!
I did a test using this approach:
The editor
variable contains the necessary attributes to identify the user's selection.
Thanks, will test it and add "auto track location" as an option.
Done.
Implemented in Release v1.14.0.
Thank you for your contribution.
Wonder @oleg-shilo ,
worked perfectly. Glad to have helped!
Issue Type: Feature Request
It would be helpful to highlight in the codemap the current location of the cursor in the file.