Fix Y on last line with no trailing new line
For zed-industries/community#2044
This commit is contained in:
parent
7c77baa7c1
commit
b02bd9bce1
4 changed files with 29 additions and 3 deletions
|
@ -12,7 +12,7 @@ use language::{Selection, SelectionGoal};
|
|||
use workspace::Workspace;
|
||||
|
||||
use crate::{
|
||||
motion::Motion,
|
||||
motion::{start_of_line, Motion},
|
||||
object::Object,
|
||||
state::{Mode, Operator},
|
||||
utils::copy_selections_content,
|
||||
|
@ -326,7 +326,10 @@ pub fn yank(_: &mut Workspace, _: &VisualYank, cx: &mut ViewContext<Workspace>)
|
|||
let line_mode = editor.selections.line_mode;
|
||||
copy_selections_content(editor, line_mode, cx);
|
||||
editor.change_selections(None, cx, |s| {
|
||||
s.move_with(|_, selection| {
|
||||
s.move_with(|map, selection| {
|
||||
if line_mode {
|
||||
selection.start = start_of_line(map, false, selection.start);
|
||||
};
|
||||
selection.collapse_to(selection.start, SelectionGoal::None)
|
||||
});
|
||||
if vim.state().mode == Mode::VisualBlock {
|
||||
|
@ -672,6 +675,21 @@ mod test {
|
|||
the lazy dog"})
|
||||
.await;
|
||||
cx.assert_clipboard_content(Some("The q"));
|
||||
|
||||
cx.set_shared_state(indoc! {"
|
||||
The quick brown
|
||||
fox ˇjumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["shift-v", "shift-g", "shift-y"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
The quick brown
|
||||
ˇfox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.assert_shared_clipboard("fox jumps over\nthe lazy dog\n")
|
||||
.await;
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue