-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
support word and line completion #4816
Conversation
QiBaobin
commented
Nov 19, 2022
It looks like this works by shelling out to |
@the-mikedavis Good point, fixed. |
let matches = grep_impl( | ||
&query, | ||
current_content, | ||
if search_root { Some(config) } else { None }, | ||
match_whold_line, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we either want to only use open buffers or current buffer. Scanning the entire tree can easily be very costly and tons of disk I/O.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very useful for editing source code without lsp, and completing lines is also very useful for writing similar logic in other files even there is a lsp.
We don't scan the file tree for C-x or idle completions, only do it when manually trigger by C-n and C-l, but also limit the match count to a few number.
completion_grep( | ||
cx, | ||
format!(r"\b{}\w+", prefix,), | ||
start_offset, | ||
search_root, | ||
false, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a regex to extract words is a lot less efficient than just scanning the rope. Here's another approach that does that #3328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we use this to search external files too just like global_search, we don't load the content into a Rope, right? If it makes sense to change the logic to extract words from the matched lines, I can do the change there.
let all_matches: Vec<FileResult> = | ||
UnboundedReceiverStream::new(all_matches_rx).collect().await; | ||
let all_matches: Vec<FileResult> = UnboundedReceiverStream::new(all_matches_rx) | ||
.map(|(path, _, line_num)| FileResult::new(&path, line_num as usize - 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems more wasteful to do this upfront rather than calculating it for matches only (after search_path)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you guiding me how to write a common function or sink that accepts a transform lambda? I am stuck there, so I send all three fields to the channel.
I really need word completion, does any one know when it's going to happen, thanks |