Avoid switching to visual mode when following in vim mode
Co-authored-by: Keith Simmons <keith@zed.dev>
This commit is contained in:
parent
c53412efcb
commit
42cd2ae142
2 changed files with 10 additions and 4 deletions
|
@ -1025,6 +1025,10 @@ impl Editor {
|
||||||
self.buffer.read(cx).replica_id()
|
self.buffer.read(cx).replica_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn leader_replica_id(&self) -> Option<ReplicaId> {
|
||||||
|
self.leader_replica_id
|
||||||
|
}
|
||||||
|
|
||||||
pub fn buffer(&self) -> &ModelHandle<MultiBuffer> {
|
pub fn buffer(&self) -> &ModelHandle<MultiBuffer> {
|
||||||
&self.buffer
|
&self.buffer
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,12 @@ fn editor_focused(EditorFocused(editor): &EditorFocused, cx: &mut MutableAppCont
|
||||||
Vim::update(cx, |vim, cx| {
|
Vim::update(cx, |vim, cx| {
|
||||||
vim.active_editor = Some(editor.downgrade());
|
vim.active_editor = Some(editor.downgrade());
|
||||||
vim.selection_subscription = Some(cx.subscribe(editor, |editor, event, cx| {
|
vim.selection_subscription = Some(cx.subscribe(editor, |editor, event, cx| {
|
||||||
|
if editor.read(cx).leader_replica_id().is_none() {
|
||||||
if let editor::Event::SelectionsChanged { local: true } = event {
|
if let editor::Event::SelectionsChanged { local: true } = event {
|
||||||
let newest_empty = editor.read(cx).selections.newest::<usize>(cx).is_empty();
|
let newest_empty = editor.read(cx).selections.newest::<usize>(cx).is_empty();
|
||||||
editor_local_selections_changed(newest_empty, cx);
|
editor_local_selections_changed(newest_empty, cx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if editor.read(cx).mode() != EditorMode::Full {
|
if editor.read(cx).mode() != EditorMode::Full {
|
||||||
|
@ -57,7 +59,7 @@ fn editor_released(EditorReleased(editor): &EditorReleased, cx: &mut MutableAppC
|
||||||
|
|
||||||
fn editor_local_selections_changed(newest_empty: bool, cx: &mut MutableAppContext) {
|
fn editor_local_selections_changed(newest_empty: bool, cx: &mut MutableAppContext) {
|
||||||
Vim::update(cx, |vim, cx| {
|
Vim::update(cx, |vim, cx| {
|
||||||
if vim.state.mode == Mode::Normal && !newest_empty {
|
if vim.enabled && vim.state.mode == Mode::Normal && !newest_empty {
|
||||||
vim.switch_mode(Mode::Visual { line: false }, cx)
|
vim.switch_mode(Mode::Visual { line: false }, cx)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue