vim: Fix d shift-g
not deleting until EOD if soft-wrap is on (#20160)
This previously didn't work: `d G` would delete to the end of the "first of the soft-wrapped lines" of the last line. To fix it, we special case the delete behavior for `shift-g`, which is what Neovim also seems to do. Release Notes: - Fixed `d G` in Vim mode not deleting until the actual end of the document if soft-wrap is turned on.
This commit is contained in:
parent
4097118070
commit
7fb9549098
3 changed files with 51 additions and 18 deletions
|
@ -28,25 +28,30 @@ impl Vim {
|
|||
original_columns.insert(selection.id, original_head.column());
|
||||
motion.expand_selection(map, selection, times, true, &text_layout_details);
|
||||
|
||||
// Motion::NextWordStart on an empty line should delete it.
|
||||
if let Motion::NextWordStart {
|
||||
ignore_punctuation: _,
|
||||
} = motion
|
||||
{
|
||||
if selection.is_empty()
|
||||
&& map
|
||||
.buffer_snapshot
|
||||
.line_len(MultiBufferRow(selection.start.to_point(map).row))
|
||||
== 0
|
||||
{
|
||||
selection.end = map
|
||||
.buffer_snapshot
|
||||
.clip_point(
|
||||
Point::new(selection.start.to_point(map).row + 1, 0),
|
||||
Bias::Left,
|
||||
)
|
||||
.to_display_point(map)
|
||||
match motion {
|
||||
// Motion::NextWordStart on an empty line should delete it.
|
||||
Motion::NextWordStart { .. } => {
|
||||
if selection.is_empty()
|
||||
&& map
|
||||
.buffer_snapshot
|
||||
.line_len(MultiBufferRow(selection.start.to_point(map).row))
|
||||
== 0
|
||||
{
|
||||
selection.end = map
|
||||
.buffer_snapshot
|
||||
.clip_point(
|
||||
Point::new(selection.start.to_point(map).row + 1, 0),
|
||||
Bias::Left,
|
||||
)
|
||||
.to_display_point(map)
|
||||
}
|
||||
}
|
||||
Motion::EndOfDocument {} => {
|
||||
// Deleting until the end of the document includes the last line, including
|
||||
// soft-wrapped lines.
|
||||
selection.end = map.max_point()
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue