mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
vim-mode: fix cursor position after changing from Insert to Normal mode
This commit is contained in:
parent
cfbda92f67
commit
6fea8bf7dc
@ -2241,11 +2241,18 @@ void VVim::setMode(VimMode p_mode, bool p_clearSelection, int p_position)
|
||||
if (m_mode != p_mode) {
|
||||
QTextCursor cursor = m_editor->textCursorW();
|
||||
int position = p_position;
|
||||
if (position == -1
|
||||
&& m_mode == VimMode::Visual
|
||||
if (position == -1) {
|
||||
if (m_mode == VimMode::Visual
|
||||
&& p_mode == VimMode::Normal
|
||||
&& cursor.position() > cursor.anchor()) {
|
||||
position = cursor.position() - 1;
|
||||
} else if (m_mode == VimMode::Insert
|
||||
&& p_mode == VimMode::Normal) {
|
||||
position = cursor.position() - 1;
|
||||
if (position < 0) {
|
||||
position = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p_clearSelection) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user