Merge pull request #2039 from zed-industries/vim-mode-single-line-editors
disable vim mode in non full editors
This commit is contained in:
@@ -37,9 +37,7 @@ fn editor_focused(EditorFocused(editor): &EditorFocused, cx: &mut MutableAppCont
|
|||||||
let editor_mode = editor.mode();
|
let editor_mode = editor.mode();
|
||||||
let newest_selection_empty = editor.selections.newest::<usize>(cx).is_empty();
|
let newest_selection_empty = editor.selections.newest::<usize>(cx).is_empty();
|
||||||
|
|
||||||
if editor_mode != EditorMode::Full {
|
if editor_mode == EditorMode::Full && !newest_selection_empty {
|
||||||
vim.switch_mode(Mode::Insert, true, cx);
|
|
||||||
} else if !newest_selection_empty {
|
|
||||||
vim.switch_mode(Mode::Visual { line: false }, true, cx);
|
vim.switch_mode(Mode::Visual { line: false }, true, cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -84,9 +84,6 @@ async fn test_buffer_search(cx: &mut gpui::TestAppContext) {
|
|||||||
);
|
);
|
||||||
cx.simulate_keystroke("/");
|
cx.simulate_keystroke("/");
|
||||||
|
|
||||||
// We now use a weird insert mode with selection when jumping to a single line editor
|
|
||||||
assert_eq!(cx.mode(), Mode::Insert);
|
|
||||||
|
|
||||||
let search_bar = cx.workspace(|workspace, cx| {
|
let search_bar = cx.workspace(|workspace, cx| {
|
||||||
workspace
|
workspace
|
||||||
.active_pane()
|
.active_pane()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ mod visual;
|
|||||||
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use command_palette::CommandPaletteFilter;
|
use command_palette::CommandPaletteFilter;
|
||||||
use editor::{Bias, Cancel, Editor};
|
use editor::{Bias, Cancel, Editor, EditorMode};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
impl_actions,
|
impl_actions,
|
||||||
keymap_matcher::{KeyPressed, Keystroke},
|
keymap_matcher::{KeyPressed, Keystroke},
|
||||||
@@ -267,7 +267,7 @@ impl Vim {
|
|||||||
for editor in self.editors.values() {
|
for editor in self.editors.values() {
|
||||||
if let Some(editor) = editor.upgrade(cx) {
|
if let Some(editor) = editor.upgrade(cx) {
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
if self.enabled {
|
if self.enabled && editor.mode() == EditorMode::Full {
|
||||||
editor.set_cursor_shape(cursor_shape, cx);
|
editor.set_cursor_shape(cursor_shape, cx);
|
||||||
editor.set_clip_at_line_ends(state.clip_at_line_end(), cx);
|
editor.set_clip_at_line_ends(state.clip_at_line_end(), cx);
|
||||||
editor.set_input_enabled(!state.vim_controlled());
|
editor.set_input_enabled(!state.vim_controlled());
|
||||||
|
|||||||
Reference in New Issue
Block a user