alefragnani / vscode-bookmarks

Bookmarks Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=alefragnani.Bookmarks
GNU General Public License v3.0
1.7k stars 163 forks source link

[FEATURE] - Bookmark a snippet of text instead of line number #606

Closed jaseemabid closed 1 year ago

jaseemabid commented 1 year ago

I really hope this isn't a duplicate issue, apologies if so

First of all thanks a lot for this, makes navigating and surviving a monorepo much easier.

My bookmarks are very often getting out of sync, and I have noticed many different situations in which this happens. It's not easy pin point how exactly this happens, just that often you try to search for something, its not there and the bookmark is on a line few lines above or below.

  1. Adding a line on top of my bookmark seems to be making them go out of sync. Probably https://github.com/alefragnani/vscode-bookmarks/issues/540 ?
  2. Prettier + ts messing things up once in a while. The workaround isn't working reliably. I'm having issues with and without the new sticky engine.
  3. Pulling in large changes via git, changing branches etc.

I have already looked at quite a few other discussions, and I'm still not sure if this is fully resolved?


Alternatively, would it be possible to bookmark a snippet rather than line number? When I'm bookmarking line 50, I mean something like class User, and that line number is just incidental. Would it be possible to remember a text snippet and always jump to the first instance of it in a file?

If I'm not mistaken, Emacs' org-mode used to do bookmarks like this, and it should be robust against large changes?

jaseemabid commented 1 year ago

This is related to https://github.com/alefragnani/vscode-bookmarks/issues/7, but not the same as far as I understand. I'm not trying to search across the repo, just an exact match in a specific file.

I think the ask in https://github.com/alefragnani/vscode-bookmarks/issues/194 is probably very similar, but that was redirected to https://github.com/alefragnani/vscode-bookmarks/issues/77, which I'm not sure is the same thing.

alefragnani commented 1 year ago

Hi @jaseemabid ,

The bookmark positions are updated based on the info provided by VS Code when changes happens in the text. It's not an easy task to interpret that info to update the bookmarks accordingly because there are a lot of variations, and yes, there are still a few issues, even with the new engine setting. It is better, but not as good as I would like to. And because it uses info provided by VS Code, any external change to the file (like Git workflows) is not recognized.

About alternatives, I don't think adding line content/snippet would be enough to fix the remaining issues, simply because if that line itself changes, you would lose the reference. Even formatting changes would fall in this case. On the other hand, I've made some researches while developing the new engine feature, looking for alternative approaches, but decided to try out a revamp instead. The new algorithm fixed a few issues, but still needs improvement, and because of that, I'm planning to come back to the researches I've made and try out new concepts.

Thank you