-
Notifications
You must be signed in to change notification settings - Fork 26
Hitting v
in select mode does not collapse selections
#77
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
Comments
Hmm, that's not the whole story.
So there is another way to reproduce the evil-helix bug: when first making a selection and then switching windows/buffers, if you later return to the window/buffer you will be in normal mode but the selection is still there. So we need to modify |
That's an important issue you're mentioning here. I've been bothered since the beginning how I avoid selections in normal mode at local places in the code instead of at one or few central places. I wanted to avoid the slight overhead of the collapsing in |
Or keep the selections but don't render them in normal mode? Not sure, just thinking out loud. |
It's a good idea, but I fear that not showing selections while they're there might end up causing more problems than solutions. Helix doesn't exactly have this concept of hidden/secondary selections, as far as I'm aware. I had a brief look at the function, and especially when it's called: The good news is that diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index e0165bb6..3b569bc5 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -2250,6 +2250,16 @@ pub fn enter_normal_mode(&mut self) {
doc.set_selection(view.id, selection);
doc.restore_cursor = false;
}
+
+ log::warn!("enter_normal_mode() called; evil: {}", self.evil);
+ // if self.evil {
+ let text = doc.text().slice(..);
+ let selection = doc.selection(view.id).clone().transform(|range| {
+ let pos = range.cursor(text);
+ Range::new(pos, pos)
+ });
+ doc.set_selection(view.id, selection);
+ // }
}
pub fn current_stack_frame(&self) -> Option<&StackFrame> { I hope the function doesn't get called too late - i.e. after switching to the target buffer/window. PS: For some reason, |
Yeah that field is unused and can be deleted. You should be able to use |
Uh oh!
There was an error while loading. Please reload this page.
We have the following functions:
Mapped to
keys.select.esc
:Mapped to
keys.select.v
andkeys.insert.esc
(andkeys.normal.esc
, but that's a no-op):enter_normal_mode
does 3 things:editor.mode = Mode::Normal
try_restore_indent
restore_cursor
try_restore_indent
andrestore_cursor
are only relevant when exiting insert mode (perhaps a better name forenter_normal_mode
would beexit_insert_mode
).Conclusion
We should map
keys.select.v
toexit_select_mode
instead ofnormal_mode
.The text was updated successfully, but these errors were encountered: