vsc-cnst / SublimeTextFileFilter

Sublime Text plugin for filtering file content using regular expressions
MIT License
5 stars 1 forks source link

Moving viewport to cursor location #3

Closed reagle closed 2 weeks ago

reagle commented 3 weeks ago

Thank you for this package, neat! I've long used Filter Lines and your plugin doesn't create a new tab/file, rather it folds. This is advantageous for navigating to or editing text in the actual file. Some thoughts:

  1. If I place my cursor on a line in the folded view, when I hit escape the viewport shows the top of the file, rather than the line with the cursor in it. I can always move the viewport by hitting the left or right arrow (or super+k,super+c), but perhaps on escape it could show_at_center.
  2. I like that if I unfold-all, instead of escape, the highlights remain.
  3. A possible downside is that when I escape or unfold, and previous foldings I had have been lost.
vsc-cnst commented 3 weeks ago

Hi,

thank you for the positive feedback and for taking the time to suggest improvements!

Regarding nr 1

if I understand correctly, repro steps would be:

  1. Filter file
  2. Expand a folder region
  3. It escape to unfold a
  4. NOT OK: Carrer is moved to the beginning of the file -Expected result : Carrer is in the same position as before clearing the filter

Regarding nr 2

Escape key is purposely meant to clear all and exit the filter file extension - providing an easy and intuitive way to exit.

There is a command for unfolding all. This is meant to unfold all but maintaining the highlights. I’ll add a feature to make it possible to configure keyboard shortcuts for each of folding styles (e.g. ctrl+foo,ctrl+bar). This way, you can set a shortcut for unfold all file without removing the highlights.

Let me know if this will work for you.

Once again, thanks for your feedback.

reagle commented 3 weeks ago

NOT OK: Carrer is moved to the beginning of the file

My issue is not with the cursor. It's that when I escape, the viewport is at the top of the file, rather than where the cursor is. In this clip, the cursor is on line 100, I invoke your filter for all "log." lines, move the cursor to line 261, escape, and my viewport is at the top of the document instead on line 261. Moving the cursor left/right restores the viewport to line 261, but the viewport should automatically be on the cursor location (i.e., show_at_center).

file-filter-shot.webm

Regarding nr 2

Sorry for not being clear. Imagine I have already folded some of my functions. Then I use your plugin, escape, and now everything is unfolded, which annoys me because I wanted my earlier folds functions to remain folded. I don't know if it's possible (or worth it really) to save the existing folds and restore those on escaping the filter view/fold.

vsc-cnst commented 2 weeks ago

HI,

I've release a new version (2.1.0) where you will be able to configure what happens after clear command runs.

default options are

{ "on_clear_command_options":{ "unfold_regions": true, "remove_highlights": true, "center_viewport_on_carret": true } } you can override them as you need.

Hope this meets your expectations.

reagle commented 2 weeks ago

Excellent! Thank you.