git: Hard wrap in editor (#26507)
This adds the ability for the editor to implement hard wrap (similar to "textwidth" in vim). If you are typing and your line extends beyond the limit, a newline is inserted before the most recent space on the line. If you are otherwise editing the line, pasting, etc. then you will need to manually rewrap. Release Notes: - git: Commit messages are now wrapped "as you type" to 72 characters.
This commit is contained in:
parent
7bca15704b
commit
c8b782d870
4 changed files with 61 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::{motion::Motion, object::Object, state::Mode, Vim};
|
||||
use collections::HashMap;
|
||||
use editor::{display_map::ToDisplayPoint, scroll::Autoscroll, Bias, Editor, IsVimMode};
|
||||
use editor::{display_map::ToDisplayPoint, scroll::Autoscroll, Bias, Editor};
|
||||
use gpui::{actions, Context, Window};
|
||||
use language::SelectionGoal;
|
||||
|
||||
|
@ -14,7 +14,7 @@ pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
|||
vim.update_editor(window, cx, |vim, editor, window, cx| {
|
||||
editor.transact(window, cx, |editor, window, cx| {
|
||||
let mut positions = vim.save_selection_starts(editor, cx);
|
||||
editor.rewrap_impl(IsVimMode::Yes, cx);
|
||||
editor.rewrap_impl(true, cx);
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.move_with(|map, selection| {
|
||||
if let Some(anchor) = positions.remove(&selection.id) {
|
||||
|
@ -52,7 +52,7 @@ impl Vim {
|
|||
motion.expand_selection(map, selection, times, false, &text_layout_details);
|
||||
});
|
||||
});
|
||||
editor.rewrap_impl(IsVimMode::Yes, cx);
|
||||
editor.rewrap_impl(true, cx);
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
s.move_with(|map, selection| {
|
||||
let anchor = selection_starts.remove(&selection.id).unwrap();
|
||||
|
@ -83,7 +83,7 @@ impl Vim {
|
|||
object.expand_selection(map, selection, around);
|
||||
});
|
||||
});
|
||||
editor.rewrap_impl(IsVimMode::Yes, cx);
|
||||
editor.rewrap_impl(true, cx);
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
s.move_with(|map, selection| {
|
||||
let anchor = original_positions.remove(&selection.id).unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue