From b795b0eb77f4604d7b77a81380657ecb75f38e67 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:23:33 +0100 Subject: [PATCH] editor: Do not autoindent on line removals in vim mode. (#9332) Fixes #8942 Release Notes: - Fixed overeager auto-indentation on line removals in Vim mode. --- crates/editor/src/editor.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1db383e6ebf2dba7c80e3569cff6313f2d46222d..aa1081e509791dbe791e583d536c64254ab33784 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -101,6 +101,7 @@ use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsStore}; use smallvec::SmallVec; use snippet::Snippet; +use std::ops::Not as _; use std::{ any::TypeId, borrow::Cow, @@ -2951,13 +2952,10 @@ impl Editor { } pub fn insert(&mut self, text: &str, cx: &mut ViewContext) { - self.insert_with_autoindent_mode( - text, - Some(AutoindentMode::Block { - original_indent_columns: Vec::new(), - }), - cx, - ); + let autoindent = text.is_empty().not().then(|| AutoindentMode::Block { + original_indent_columns: Vec::new(), + }); + self.insert_with_autoindent_mode(text, autoindent, cx); } fn insert_with_autoindent_mode(