Skip to content
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

Global marks throwing errors and not reusing existing tabs #1223

Open
Tracked by #1262
roqvist opened this issue May 31, 2023 · 10 comments
Open
Tracked by #1262

Global marks throwing errors and not reusing existing tabs #1223

roqvist opened this issue May 31, 2023 · 10 comments
Labels
bug Something isn't working manager: buffer priority

Comments

@roqvist
Copy link

roqvist commented May 31, 2023

NVIM v0.9.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

vscode-neovim v0.0.97

VSCode Version: Tried multiple; 1.78.2, 1.79.0-insider

Steps to reproduce:

  • Open a VScode folder with two or more files

image

  • Double click one of the files in the file browser to open it in a VSCode tab

image

  • Double click another file in the file browser to open a second VSCode tab

image

  • Place a global mark anywhere in the second opened tab, e.g. mA

  • Move back to the first opened tab

  • Try to move to the placed mark, e.g. 'A

    • Expected: The existing tab opens up, placing the cursor on the marked line

    • Actual: The file will be opened in a new (untitled) tab, cursor placed on top

      image

  • Close this untitled tab

  • Manually click on the second tab (the one where you initially placed the global mark)

Two errors are shown:

2023-05-31T15:14:20.901Z BufferManager: nvim_win_set_cursor: Cursor position outside buffer
2023-05-31T15:14:20.903Z BufferManager: Unable to determine neovim windows id for editor viewColumn: 1, docUri: file:///c%3A/whatever/path/to/your/file

image

@owenstake
Copy link

+1

@justinmk justinmk added the bug Something isn't working label Jun 19, 2023
@martin-braun
Copy link
Contributor

martin-braun commented Jul 2, 2023

I'm thinking about installing Bookmarks and mapping all mark actions to the appropriate commands of it (it it supports auto-naming via keymaps that is). (nope)

It's unfortunate that VSCode doesn't have native bookmarks that we could leverage for this feature, and VSCode doesn't provide an API to jump to a specific line in a file while re-using opened tabs to do so, as far as I can tell.

@dangkhoipro
Copy link

I wonder if we can learn something from this bookmark extension https://marketplace.visualstudio.com/items?itemName=alefragnani.Bookmarks

@xiyaowong
Copy link
Collaborator

xiyaowong commented Sep 15, 2023

@dangkhoipro Will support vim native global marks in the future, but using other extensions is also a great option. You can invoke their commands through mappings.

@martin-braun
Copy link
Contributor

martin-braun commented Sep 15, 2023

@dangkhoipro No, it's closed source and you cannot reproduce Vim behavior closely in this one. Since it is closed source, there is no hope in modifying the extension so that it works with vim-alike mappings.

@dangkhoipro
Copy link

@dangkhoipro Will support vim native global marks in the future, but using other extensions is also a great option. You can invoke their commands through mappings.

I'm looking forward to it, thanks!

@spacian
Copy link

spacian commented Nov 9, 2023

This extension seems to mirror Vim behavior quite well:
https://github.com/ExPixel/codemarks

It's still working like a charm for me, despite being 5 years old. @dangkhoipro @martin-braun

@Wozacosta
Copy link

Wozacosta commented Nov 24, 2023

@spacian ditto, using this one and working like a charm.

I did have to add this to my settings.json for it to work almost like on neovim:

  {
    "key": "'",
    "command": "codemarks.listMarks"
  },
  {
    "key": "m",
    "command": "codemarks.createMark",
    "when": "editorTextFocus"
  },
  {
    "key": "cmd+;",
    "command": "-codemarks.createMark",
    "when": "editorTextFocus"
  },

@martin-braun
Copy link
Contributor

@spacian But it has no support for capital letters that will allow you to jump to a different file, or has it? Will vscode-neovim work properly with it?

@Wozacosta Thanks for the bindings.

@spacian
Copy link

spacian commented Jan 10, 2024

@martin-braun it has all the features you want AFAIK. I'm using it specifically with vscode-neovim. I based a jumplist extension on it because I find the native vscode jump list rather unusable, I can walk you through the API used there: https://github.com/spacian/jumplist

The main function you are probably looking for is jumpTo(...) in src/jump_list_handler.ts.
vscode.window.showTextDocument(...) tries to open a text document by its uri. The uri is just saved when a mark or jump point is created.
The next 2 lines just make sure that the file was opened properly.
Then you create a selection based on the position of the mark (or jump point in my case) and set the active editor's selection to that selection with vscode.window.activeTextEditor.selection = selection.
Lastly, you center the new selection with vscode.window.activeTextEditor.revealRange(...)

A bunch of handling of file changes (which change mark or jump point positions) as well as file renames and deletions are handled rather naive in src/jump_list_updater.ts. But they work. And if it helps to make proper marks and a proper jump list vscode-neovim-native, all the better ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working manager: buffer priority
Projects
None yet
Development

No branches or pull requests

9 participants