Don't show autocomplete after backspacing over whitespace#937
Merged
dzhou121 merged 5 commits intolapce:masterfrom Aug 9, 2022
Merged
Don't show autocomplete after backspacing over whitespace#937dzhou121 merged 5 commits intolapce:masterfrom
dzhou121 merged 5 commits intolapce:masterfrom
Conversation
dzhou121
reviewed
Aug 7, 2022
lapce-data/src/editor.rs
Outdated
| }; | ||
|
|
||
| if start > &0 && end > &0 && end > start { | ||
| let slice = &doc[*start..*end]; |
Collaborator
There was a problem hiding this comment.
You could use the slice_to_cow on the rope to make it more efficient without converting the rope to a string.
https://github.com/lapce/lapce/blob/master/lapce-core/src/buffer.rs#L931
Contributor
Author
There was a problem hiding this comment.
Would you pass the Rope to show_completion(...)? Because slice_to_cow takes a Range as argument it would end up something like this:
fn show_completion(cmd: &EditCommand, doc: &Rope, deltas: &[(RopeDelta, InvalLines)]) -> bool {
[...]
if start > &0 && end > start {
!doc.slice_to_cow(*start..*end)
.chars()
.all(|c| c.is_whitespace() || c.is_ascii_whitespace())
} else {
true
}I'll have to try if this works and update with results 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #743
Added
EditCommand::DeleteBackwardandEditCommand::DeleteForwardto the match statement that checks for whitespace commands. On receiving one of these commands the deleted string gets checked if it's all whitespace.Added
EditCommand::UndoandEditCommand::Redoto the check, because i think it's not necessary to show autocompletion after an undo or redo.Maybe it would make sense to extract this into a function?