mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-20 01:41:40 +03:00
Only restore cursor position after an append if we still have cursor > anchor
Fixes #1158
This commit is contained in:
parent
2475ffa612
commit
aa7241067e
@ -988,7 +988,7 @@ class Insert : public InputMode
|
|||||||
public:
|
public:
|
||||||
Insert(InputHandler& input_handler, InsertMode mode, int count)
|
Insert(InputHandler& input_handler, InsertMode mode, int count)
|
||||||
: InputMode(input_handler),
|
: InputMode(input_handler),
|
||||||
m_insert_mode(mode),
|
m_restore_cursor(mode == InsertMode::Append),
|
||||||
m_edition(context()),
|
m_edition(context()),
|
||||||
m_completer(context()),
|
m_completer(context()),
|
||||||
m_autoshowcompl(true),
|
m_autoshowcompl(true),
|
||||||
@ -1003,7 +1003,7 @@ public:
|
|||||||
last_insert().keys.clear();
|
last_insert().keys.clear();
|
||||||
last_insert().disable_hooks = context().hooks_disabled();
|
last_insert().disable_hooks = context().hooks_disabled();
|
||||||
context().hooks().run_hook("InsertBegin", "", context());
|
context().hooks().run_hook("InsertBegin", "", context());
|
||||||
prepare(m_insert_mode, count);
|
prepare(mode, count);
|
||||||
|
|
||||||
if (context().has_client() and
|
if (context().has_client() and
|
||||||
context().options()["readonly"].get<bool>())
|
context().options()["readonly"].get<bool>())
|
||||||
@ -1014,10 +1014,13 @@ public:
|
|||||||
~Insert() override
|
~Insert() override
|
||||||
{
|
{
|
||||||
auto& selections = context().selections();
|
auto& selections = context().selections();
|
||||||
for (auto& sel : selections)
|
if (m_restore_cursor)
|
||||||
{
|
{
|
||||||
if (m_insert_mode == InsertMode::Append and sel.cursor().column > 0)
|
for (auto& sel : selections)
|
||||||
sel.cursor() = context().buffer().char_prev(sel.cursor());
|
{
|
||||||
|
if (sel.cursor() > sel.anchor() and sel.cursor().column > 0)
|
||||||
|
sel.cursor() = context().buffer().char_prev(sel.cursor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
selections.avoid_eol();
|
selections.avoid_eol();
|
||||||
}
|
}
|
||||||
@ -1299,13 +1302,13 @@ private:
|
|||||||
buffer.check_invariant();
|
buffer.check_invariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertMode m_insert_mode;
|
ScopedEdition m_edition;
|
||||||
ScopedEdition m_edition;
|
InsertCompleter m_completer;
|
||||||
InsertCompleter m_completer;
|
bool m_restore_cursor;
|
||||||
bool m_autoshowcompl;
|
bool m_autoshowcompl;
|
||||||
Timer m_idle_timer;
|
Timer m_idle_timer;
|
||||||
bool m_in_end = false;
|
bool m_in_end = false;
|
||||||
MouseHandler m_mouse_handler;
|
MouseHandler m_mouse_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user