Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
Conrad Irwin
ada0523043 Fix mouse selection
Co-Authored-By: WindSoilder <WindSoilder@outlook.com>
2024-02-02 16:36:51 -07:00
WindSoilder
aeb8535468 Merge branch 'main' into vim_click 2024-02-01 06:59:01 +08:00
WindSoilder
a082b93260 single click convert from virual mode to normal mode 2024-01-29 20:41:36 +08:00

View file

@ -204,7 +204,8 @@ impl Vim {
let editor = editor.read(cx);
if editor.leader_peer_id().is_none() {
let newest = editor.selections.newest::<usize>(cx);
local_selections_changed(newest, cx);
let is_multicursor = editor.selections.count() > 1;
local_selections_changed(newest, is_multicursor, cx);
}
}
EditorEvent::InputIgnored { text } => {
@ -626,13 +627,24 @@ impl Settings for VimModeSetting {
}
}
fn local_selections_changed(newest: Selection<usize>, cx: &mut WindowContext) {
fn local_selections_changed(
newest: Selection<usize>,
is_multicursor: bool,
cx: &mut WindowContext,
) {
Vim::update(cx, |vim, cx| {
if vim.enabled && vim.state().mode == Mode::Normal && !newest.is_empty() {
if matches!(newest.goal, SelectionGoal::HorizontalRange { .. }) {
vim.switch_mode(Mode::VisualBlock, false, cx);
} else {
vim.switch_mode(Mode::Visual, false, cx)
if vim.enabled {
if vim.state().mode == Mode::Normal && !newest.is_empty() {
if matches!(newest.goal, SelectionGoal::HorizontalRange { .. }) {
vim.switch_mode(Mode::VisualBlock, false, cx);
} else {
vim.switch_mode(Mode::Visual, false, cx)
}
} else if newest.is_empty()
&& !is_multicursor
&& [Mode::Visual, Mode::VisualLine, Mode::VisualBlock].contains(&vim.state().mode)
{
vim.switch_mode(Mode::Normal, true, cx)
}
}
})