Introduce AutoindentMode parameter to Buffer::edit

This controls whether or not we preserve the relative indentation
of inserted text blocks.

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
This commit is contained in:
Max Brunsfeld 2022-07-28 14:03:31 -07:00
parent cdf6ae25bb
commit fa5af4383d
18 changed files with 308 additions and 236 deletions

View file

@ -13,7 +13,7 @@ use change::init as change_init;
use collections::HashSet;
use editor::{Autoscroll, Bias, ClipboardSelection, DisplayPoint};
use gpui::{actions, MutableAppContext, ViewContext};
use language::{Point, SelectionGoal};
use language::{AutoindentMode, Point, SelectionGoal};
use workspace::Workspace;
use self::{change::change_over, delete::delete_over, yank::yank_over};
@ -278,7 +278,7 @@ fn paste(_: &mut Workspace, _: &Paste, cx: &mut ViewContext<Workspace>) {
}
}
drop(snapshot);
buffer.edit_with_autoindent(edits, cx);
buffer.edit(edits, Some(AutoindentMode::Independent), cx);
});
editor.change_selections(Some(Autoscroll::Fit), cx, |s| {

View file

@ -3,7 +3,7 @@ use std::borrow::Cow;
use collections::HashMap;
use editor::{display_map::ToDisplayPoint, Autoscroll, Bias, ClipboardSelection};
use gpui::{actions, MutableAppContext, ViewContext};
use language::SelectionGoal;
use language::{AutoindentMode, SelectionGoal};
use workspace::Workspace;
use crate::{motion::Motion, state::Mode, utils::copy_selections_content, Vim};
@ -254,7 +254,7 @@ pub fn paste(_: &mut Workspace, _: &VisualPaste, cx: &mut ViewContext<Workspace>
}
}
drop(snapshot);
buffer.edit_with_autoindent(edits, cx);
buffer.edit(edits, Some(AutoindentMode::Independent), cx);
});
editor.change_selections(Some(Autoscroll::Fit), cx, |s| {