Closed brillout closed 3 years ago
The design of the command is such that it searches from the cursor position forwards by default. To search backwards, the backwards
parameter can be set. So, I would not consider this a bug.
Nevertheless, I can see the use of being able to search the entire file. I guess the cleanest solution would be to add a new parameter that wraps around when the end or beginning of the file is encountered. Is that something you could live with?
Yes a parameter would be fantastic.
The design of the command is such that it searches from the cursor position forwards by default. To search backwards, the backwards parameter can be set. So, I would not consider this a bug.
Yes I did suspect that it was a design decision on your part :-).
I can't speak for others but I'd guess that most people would expect a search to go through the entire file. E.g. vscode's Ctrl + F
search does that. Maybe I'd set the parameter to true
by default.
Anyways I'm already happy if I can opt-in with a parameter.
Yes I did suspect that it was a design decision on your part :-).
Btw. I'm curious: why did you design it that way?
I chose the design to allow using the same command for jumping to a specific character(s). Like with Vim's f
and t
commands:
fX to next 'X' after cursor, in the same line (X is any character)
FX to previous 'X' before cursor (f and F put the cursor on X)
tX til next 'X' (similar to above, but cursor is before X)
TX til previous 'X'
If you always want to start the find from the beginning there is an easy workaround: use the cursorTop
command to move the cursor to the beginning before starting the search. Like this:
[
"cursorTop",
{
"command": "modaledit.search",
"args": {
"caseSensitive": true
}
}
]
In version 2.0 there is a new parameter wrapAround
for the search command. It jumps to top or bottom depending on the search direction when the search string is not found.
If I make a forward-search at the end of the file then I won't get any result because forward search only searches from current line to end of file. It doesn't consider any previous lines.
In my experience this is unusual.
What do you think of making
modaledit.search
always search the entire file instead?