dusk125 / sublime-betterbookmarks

BetterBookmarks extends the built-in Sublime Text 3 bookmarking system to allow for persistent bookmarks and bookmark layers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When going to a bookmark when "mark_whole_line": true, the line is selected

reagle opened this issue · comments

When going to a bookmark when "mark_whole_line": true, the line is selected counter to defaults.

Currently, this is expected behavior; when I created this option, I wasn't concerned with the selection when marking an entire line.
How would you like this to behave?

Principle of least astonishment: line should not be selected, as is the case with default bookmarks and default option of "mark_whole_line": false. Otherwise, if I plan to type, if line is selected I might over-write the whole line.

Fair enough, would adding the bookmark to the beginning of the line, with no selection, be acceptable?

The original idea for "mark_whole_line" was to only allow one mark per line; so the bookmark could be toggled from anywhere on the line. Maybe a rename of this option would be appropriate as well.

Thoughts?

Thanks for the explanation. Based on the prose description, rather than the configuration variable name, which I only read of later, I thought that one could Mark anywhere in a line, but you could only Mark once per line. Going to the bookmark would restore the cursor to the place in the line where the bookmark was made. But toggling the bookmark anywhere in the line could turn it off. This was just my initial impression. If you want to keep the current functionality, I would just tweak the prose description. Another option would be to place the Mark at the first non-white space character in the line, without selecting the line. Or, selection could actually be another configuration variable.

In v1.2.0 (released today), I changed "mark_whole_line" to "marking_mode" which can have one of two values (right now).
Those values are:

  1. selection - This mode adds one bookmark for an entire selection. Overlapping selections combine into a larger bookmark (this is native Sublime behavior).
  2. line - This mode adds an individual bookmark for each line in a selection.

I hope these new options make more sense than the previous one. If you have any other ideas for these modes, please let me know here.
If you're satisfied with these new modes, please close this issue.

Thanks and Happy Holidays!

Whoops... I hit the wrong button....

Hi, returning to this plugin and issue after a few months. I appreciate that mark_mode permits one to specify whether you can have one mark or many per line (that was a concern). However, my primary concern was that when cycling to the previous or next mark, the text or line is selected. This pollutes my copy/paste buffer. Default ST behavior is to move the cursor to the mark, not select it as well.

To clarify, right now two things are coupled: more than one mark per line and ability to mark a selection (including no selection).

  • I like one mark per line, but setting "marking_mode": "line" results in the whole line being selected when I cycle to a mark.
  • When I cycle to a mark, I don't want the text to be selected. This can be achieved with "marking_mode": "selection" but this also means there can be more than one mark on a single line.

I still haven't been able to figure this out. When mode == "line" you add a Region to the layer's marks (eg [(4993, 5021)]). The problem is that when you cycle to one of these marks, it highlights the whole line, which is different than the behavior of mode == "selection", which adds a Selection (eg <sublime.Selection object at 0x109b2ad90>). In the first case, if you start typing, it overwrites the whole line. In the second, if you start typing, it inserts where the cursor is.

I forked the code and added some comments to try to understand, a question, as well as a hack that goes to the beginning of the line in line mode (rather than the whole line being selected).