alefragnani / vscode-bookmarks

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

[FEATURE] - Keep the text while input label #651

Closed Erimus-Koo closed 8 months ago

Erimus-Koo commented 9 months ago
alefragnani commented 8 months ago

Hi @Erimus-Koo ,

I'm not sure I did understand your scenarios/steps correctly, as I couldn't reproduce it, so I have a few questions:

Thanks in advance

Erimus-Koo commented 8 months ago

Case 1

  1. cmd+opt+K toggle a bookmark on.

    image
  2. Try to edit it. Click the pencil icon and get a blank input.

    image
  3. I hope the input includes const initHandler = (

Case 2

Directly right-click at the left of the line number, and create a bookmark with label, same as the previous step 2.


And I have already checked Use Workaround For Formatters, but the bookmarks still frequently shift a few lines, which really has a significant impact.

In addition, if toggle bookmark is pressed in a multi-cursor situation, it will add many bookmarks that cannot be undone. It may be worth considering adding an option to disable this behavior.

Erimus-Koo commented 8 months ago

And I have already checked Use Workaround For Formatters, but the bookmarks still frequently shift a few lines, which really has a significant impact.

This situation often occurs when there are too many function parameters. Prittier automatically splits the parameters into multiple lines or merges them into fewer lines if the number of parameters decreases, causing the bookmark to be offset.

alefragnani commented 8 months ago

Hi @Erimus-Koo ,

The Case 1 is the expected behavior, as the idea of the Edit Label button is to edit the label of the bookmark. In this case, you have a regular bookmark (without label) and the preview shown in the side bar is just the line content. When you click the Edit Label button, since the bookmark is not labeled, it will not suggest any label. The bookmarks.label.suggestion setting only works for selections, which is not the case.

The Case 2, on the other hand, I couldn't reproduce the issue. When I click the Edit Label button on a labeled bookmark, its label is shown in the Input Box

image

Are you sure you edited a labeled bookmark? It has a ✏️ icon side by side the bookmark icon in the side bar.

About the bookmark shifting while using Prettier, and the setting to disable multi-cursor support, I'll open two separate issues to track.

Hope this helps

Erimus-Koo commented 8 months ago

Yeah, in case 2, I'm creating a new bookmark with the label, not editing a labeled bookmark, so it's the same issue about the suggest. I prefer to keep the content of the line as suggestion.

And in my usage, I find an automatically generated and updated TOC for functions that will be very helpful. It would be great if this could be a feature.

alefragnani commented 8 months ago

For your case 2, if you like the suggestion to be the line content, I suggest you to try out the following setting:

    "bookmarks.label.suggestion": "suggestWhenSelectedOrLineWhenNoSelected",

As it, Suggests the selected text (if available) or the entire line (when has no selection). You still need to confirm

Hope this helps