Closed masmu closed 2 months ago
Looks good to me.
But this didn't work, since
BufPane.FindNext()
andBufPane.FindPrevious()
always returntrue
, which prevents all subsequent actions from being executed. I'm not sure if this is intentional for some reason. It seems more likely that this case was omitted or forgotten because it generally excludes the possibility of chaining actions.
Just omitted, I believe. Like in the vast majority of actions. I wrote about it a long time ago in https://github.com/zyedidia/micro/issues/2755#issuecomment-1436000051 (and I still think it would be good to improve all those actions as well).
Just omitted, I believe. Like in the vast majority of actions. I wrote about it a long time ago in #2755 (comment) (and I still think it would be good to improve all those actions as well).
How about now and here? Otherwise it will be a good idea/intention, but not more and we forget about it again.
How about now and here? Otherwise it will be a good idea/intention, but not more and we forget about it again.
Absolutely.
I would be happy to have a look. But due to time constraints, I hope it's okay if this can happen at the end of next week at the earliest.
No worries, we're not in hurry.
I didn't mean that it must be @masmu who has to implement it. :)
How about now and here? Otherwise it will be a good idea/intention, but not more and we forget about it again.
FYI I'm gonna push a PR soon.
See #3352.
This is a small feature to reset previously initiated searches and to use
FindNext
andFindPrevious
in chained actions.Personally I never could get used to use different shortcuts for initiating and continuing a search. (First
Ctrl-f
, thenCtrl-n
orCtrl-p
)Assuming that the option
hlsearch
is set tofalse
, my preferred workflow is:Initiation of a search:
Ctrl-f
(to open the search query box in the command bar)Enter
to start the search Expectation: The first occurrence of the search term is being highlightedContinuation of a previously initiated search:
Enter
to continue the search Expectation: The next occurrence of the search term is being highlighted. You can repeat this step as often as you like. EachEnter
highlights the next occurrence.Exit the search operation when you found what you are looking for
Esc
to exit Expectation: The search term found is still highlighted and you can continue with normal text editing.To achieve this chaining actions seems like the way to go. Like:
But this didn't work, since
BufPane.FindNext()
andBufPane.FindPrevious()
always returntrue
, which prevents all subsequent actions from being executed. I'm not sure if this is intentional for some reason. It seems more likely that this case was omitted or forgotten because it generally excludes the possibility of chaining actions.Buffer.FindNext()
handles the case of a search term being empty. But it would also reset the selection when adding areturn false
there. So adding a guard clause at the top of the function may be the best solution and should not break any potential user bindings out there.The missing piece left was to add
ResetSearch()
which allows to exit a previously initiated search. Like:Just as a bonus: The following snippet adds a visual representation for being in search mode to the status line, which is IMHO quite nice.