mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
This commit is contained in:
parent
f798be6e27
commit
1f3e009b32
@ -126,10 +126,15 @@ pub fn visual_block_motion(
|
||||
let map = &s.display_map();
|
||||
let mut head = s.newest_anchor().head().to_display_point(map);
|
||||
let mut tail = s.oldest_anchor().tail().to_display_point(map);
|
||||
let mut goal = s.newest_anchor().goal;
|
||||
|
||||
let (start, end) = match s.newest_anchor().goal {
|
||||
SelectionGoal::ColumnRange { start, end } if preserve_goal => (start, end),
|
||||
SelectionGoal::Column(start) if preserve_goal => (start, start + 1),
|
||||
_ => (tail.column(), head.column()),
|
||||
};
|
||||
let goal = SelectionGoal::ColumnRange { start, end };
|
||||
|
||||
let was_reversed = tail.column() > head.column();
|
||||
|
||||
if !was_reversed && !preserve_goal {
|
||||
head = movement::saturating_left(map, head);
|
||||
}
|
||||
@ -149,13 +154,6 @@ pub fn visual_block_motion(
|
||||
head = movement::saturating_right(map, head)
|
||||
}
|
||||
|
||||
let (start, end) = match goal {
|
||||
SelectionGoal::ColumnRange { start, end } if preserve_goal => (start, end),
|
||||
SelectionGoal::Column(start) if preserve_goal => (start, start + 1),
|
||||
_ => (tail.column(), head.column()),
|
||||
};
|
||||
goal = SelectionGoal::ColumnRange { start, end };
|
||||
|
||||
let columns = if is_reversed {
|
||||
head.column()..tail.column()
|
||||
} else if head.column() == tail.column() {
|
||||
@ -791,6 +789,26 @@ mod test {
|
||||
"
|
||||
})
|
||||
.await;
|
||||
|
||||
//https://github.com/zed-industries/community/issues/1950
|
||||
cx.set_shared_state(indoc! {
|
||||
"Theˇ quick brown
|
||||
|
||||
fox jumps over
|
||||
the lazy dog
|
||||
"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["l", "ctrl-v", "j", "j"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
"The «qˇ»uick brown
|
||||
|
||||
fox «jˇ»umps over
|
||||
the lazy dog
|
||||
"
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -30,3 +30,9 @@
|
||||
{"Key":"o"}
|
||||
{"Key":"escape"}
|
||||
{"Get":{"state":"Theˇouick\nbroo\nfoxo\njumo over the\n\nlazy dog\n","mode":"Normal"}}
|
||||
{"Put":{"state":"Theˇ quick brown\n\nfox jumps over\nthe lazy dog\n"}}
|
||||
{"Key":"l"}
|
||||
{"Key":"ctrl-v"}
|
||||
{"Key":"j"}
|
||||
{"Key":"j"}
|
||||
{"Get":{"state":"The «qˇ»uick brown\n\nfox «jˇ»umps over\nthe lazy dog\n","mode":"VisualBlock"}}
|
||||
|
Loading…
Reference in New Issue
Block a user