Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?] Search doesn't search entire file #8

Closed
brillout opened this issue Apr 10, 2020 · 5 comments
Closed

[Bug?] Search doesn't search entire file #8

brillout opened this issue Apr 10, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@brillout
Copy link

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?

@johtela
Copy link
Owner

johtela commented Apr 13, 2020

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?

@johtela johtela added the enhancement New feature or request label Apr 13, 2020
@brillout
Copy link
Author

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.

@brillout
Copy link
Author

Yes I did suspect that it was a design decision on your part :-).

Btw. I'm curious: why did you design it that way?

@johtela
Copy link
Owner

johtela commented Apr 17, 2020

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
            }
        }
]

johtela pushed a commit that referenced this issue May 29, 2020
and `wrapAround` argument (#8) to the search command.
Documentation still TBD.
@johtela
Copy link
Owner

johtela commented Jul 30, 2020

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.

@johtela johtela closed this as completed Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants