alefragnani / vscode-bookmarks

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

[FEATURE] - Keep bookmark even when associated line is deleted #503

Closed SofieneOuerdiane closed 2 years ago

SofieneOuerdiane commented 2 years ago

Hello,

It seems that when the line to which the bookmark is attached is deleted, the bookmark is also deleted. It will be great to make bookmarks persistent even when the line to which there are attached got deleted.

Regards

alefragnani commented 2 years ago

Hi @SofieneOuerdiane ,

Yes, this is how the extension is designed. The Bookmark is tied to the line, so if you delete the line, the bookmark is deleted as well. I have used a few editor/IDEs and never noticed this behavior, and that’s why the extension works this way.

Let’s see how other users react to this request.

Hope this helps

SofieneOuerdiane commented 2 years ago

Hello,

Thank you for your reply. I understand your point of view. However I believe with this approach, bookmarks can be easily lost without any traces to get them back. I would argue the best approach would be to attach bookmark to line number instead of the line itself.

Regards

alefragnani commented 2 years ago

If you attach the bookmark to the line number, whenever a change is made above a bookmark (new lines being added or some lines being deleted), the bookmarks will not represent the original piece of code anymore. That's the reason why this extension updates the bookmarks when your file changes. They will remain tied to some function, class, tag, or whatever content you would like to go back easily.

Right now I have only Atom and IntelliJ installed, and both works exactly the same. When you delete a line with a bookmark or a breakpoint (in IntelliJ), the bookmark/breakpoint is deleted as well. These apps weren't the reasons why I made this way, but are examples of similar approach.

On the other hand, VS Code breakpoints works the way you described. When you delete the line, the breakpoint moves to the next line. Doing a quick test I already found an issue on this behavior. If you Undo the line deletion, the breakpoint doesn't undo as well, remaining in the next line. I imagine why they (the VS Code team) decided this approach, and TBH, the Bookmarks extension should follow the same approach.

But, you may be more interested in the line numbers itself, instead of the file content. If that's the case, I'm sorry to say but this extension doesn't work this way.

Hope this helps

alefragnani commented 2 years ago

See https://github.com/alefragnani/vscode-numbered-bookmarks/issues/27#issuecomment-1021743169 for details on how this should work