Commit a30e66f2 authored by Thorben Kroeger's avatar Thorben Kroeger Committed by hjk
Browse files

FakeVim: implement C-r{register} in insert mode



In normal mode:
input: |aaa bbb
keys: yiw A C-r 0
result: aaa bbbaaa

Change-Id: Ifb2ac8603adf9c897d169f4ab282a3ee97896684
Reviewed-by: default avatarLukas Holecek <hluk@email.cz>
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent c7fa1a92
......@@ -2526,6 +2526,14 @@ void FakeVimPlugin::test_vim_copy_paste()
// yank register is only used for y{motion} commands
data.setText("aaa bbb ccc");
KEYS("yiwwdiw\"0P", "aaa aaa ccc");
// paste register in insert mode
data.setText("aaa bbb ccc ");
KEYS("yiwA<C-r>0", "aaa bbb ccc aaa");
KEYS("<C-r><Esc>x", "aaa bbb ccc aaax");
KEYS("<Esc>dd", "");
data.setText("aaa bbb");
KEYS("\"ayawA<C-r>a", "aaa bbbaaa ");
}
void FakeVimPlugin::test_vim_undo_redo()
......
......@@ -193,7 +193,8 @@ enum SubMode
ReplaceSubMode, // Used for r
MacroRecordSubMode, // Used for q
MacroExecuteSubMode, // Used for @
CtrlVSubMode // Used for Ctrl-v in insert mode
CtrlVSubMode, // Used for Ctrl-v in insert mode
CtrlRSubMode // Used for Ctrl-r in insert mode
};
/*! A \e SubSubMode is used for things that require one more data item
......@@ -3629,6 +3630,10 @@ void FakeVimHandler::Private::updateMiniBuffer()
msg = _("VISUAL BLOCK");
} else if (g.mode == InsertMode) {
msg = _("-- INSERT --");
if (g.submode == CtrlRSubMode)
msg += _(" ^R");
else if (g.submode == CtrlVSubMode)
msg += _(" ^V");
} else if (g.mode == ReplaceMode) {
msg = _("-- REPLACE --");
} else {
......@@ -4848,7 +4853,16 @@ void FakeVimHandler::Private::finishInsertMode()
void FakeVimHandler::Private::handleInsertMode(const Input &input)
{
if (input.isEscape()) {
finishInsertMode();
if (g.submode == CtrlRSubMode || g.submode == CtrlVSubMode) {
g.submode = NoSubMode;
g.subsubmode = NoSubSubMode;
updateMiniBuffer();
} else {
finishInsertMode();
}
} else if (g.submode == CtrlRSubMode) {
m_cursor.insertText(registerContents(input.asChar().unicode()));
g.submode = NoSubMode;
} else if (g.submode == CtrlVSubMode) {
if (g.subsubmode == NoSubSubMode) {
g.subsubmode = CtrlVUnicodeSubSubMode;
......@@ -4908,6 +4922,11 @@ void FakeVimHandler::Private::handleInsertMode(const Input &input)
} else if (input.isControl('v')) {
g.submode = CtrlVSubMode;
g.subsubmode = NoSubSubMode;
updateMiniBuffer();
} else if (input.isControl('r')) {
g.submode = CtrlRSubMode;
g.subsubmode = NoSubSubMode;
updateMiniBuffer();
} else if (input.isControl('w')) {
const int blockNumber = m_cursor.blockNumber();
const int endPos = position();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment