forked from qt-creator/qt-creator
FakeVim: Properly clear bad mapping
Change-Id: Ia2a1b04962976b119d2190a02aba0ec01b451e43 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -1841,8 +1841,6 @@ public:
|
|||||||
: mappings(), currentMap(&mappings), inputTimer(-1), currentMessageLevel(MessageInfo),
|
: mappings(), currentMap(&mappings), inputTimer(-1), currentMessageLevel(MessageInfo),
|
||||||
lastSearchForward(false), findPending(false), returnToMode(CommandMode)
|
lastSearchForward(false), findPending(false), returnToMode(CommandMode)
|
||||||
{
|
{
|
||||||
// default mapping state - shouldn't be removed
|
|
||||||
mapStates << MappingState();
|
|
||||||
commandBuffer.setPrompt(QLatin1Char(':'));
|
commandBuffer.setPrompt(QLatin1Char(':'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2343,7 +2341,8 @@ EventResult FakeVimHandler::Private::handleKey(const Input &input)
|
|||||||
if (!in.isValid()) {
|
if (!in.isValid()) {
|
||||||
unhandleMappedKeys();
|
unhandleMappedKeys();
|
||||||
} else {
|
} else {
|
||||||
if (handleMapped && !g.mapStates.last().noremap && m_subsubmode != SearchSubSubMode) {
|
if (handleMapped && (g.mapStates.isEmpty() || !g.mapStates.last().noremap)
|
||||||
|
&& m_subsubmode != SearchSubSubMode) {
|
||||||
if (!g.currentMap.isValid()) {
|
if (!g.currentMap.isValid()) {
|
||||||
g.currentMap.reset(currentModeCode());
|
g.currentMap.reset(currentModeCode());
|
||||||
if (!g.currentMap.walk(g.pendingInput) && g.currentMap.isComplete()) {
|
if (!g.currentMap.walk(g.pendingInput) && g.currentMap.isComplete()) {
|
||||||
@@ -2369,6 +2368,7 @@ EventResult FakeVimHandler::Private::handleKey(const Input &input)
|
|||||||
if (r != EventHandled) {
|
if (r != EventHandled) {
|
||||||
// clear bad mapping and end all started edit blocks
|
// clear bad mapping and end all started edit blocks
|
||||||
g.pendingInput.clear();
|
g.pendingInput.clear();
|
||||||
|
g.mapStates.clear();
|
||||||
while (m_editBlockLevel > 0)
|
while (m_editBlockLevel > 0)
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
return r;
|
return r;
|
||||||
@@ -2400,12 +2400,11 @@ EventResult FakeVimHandler::Private::handleDefaultKey(const Input &input)
|
|||||||
|
|
||||||
void FakeVimHandler::Private::handleMappedKeys()
|
void FakeVimHandler::Private::handleMappedKeys()
|
||||||
{
|
{
|
||||||
int maxMapDepth = g.mapStates.last().maxMapDepth - 1;
|
int maxMapDepth = g.mapStates.isEmpty() ? 1000 : g.mapStates.last().maxMapDepth - 1;
|
||||||
|
|
||||||
int invalidCount = g.currentMap.invalidInputCount();
|
int invalidCount = g.currentMap.invalidInputCount();
|
||||||
if (invalidCount > 0) {
|
if (invalidCount > 0) {
|
||||||
g.mapStates.remove(g.mapStates.size() - invalidCount, invalidCount);
|
g.mapStates.remove(0, invalidCount);
|
||||||
QTC_CHECK(!g.mapStates.empty());
|
|
||||||
for (int i = 0; i < invalidCount; ++i)
|
for (int i = 0; i < invalidCount; ++i)
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
}
|
}
|
||||||
@@ -2427,11 +2426,11 @@ void FakeVimHandler::Private::handleMappedKeys()
|
|||||||
|
|
||||||
void FakeVimHandler::Private::unhandleMappedKeys()
|
void FakeVimHandler::Private::unhandleMappedKeys()
|
||||||
{
|
{
|
||||||
if (g.mapStates.size() == 1)
|
if (g.mapStates.isEmpty())
|
||||||
return;
|
return;
|
||||||
g.mapStates.pop_back();
|
g.mapStates.pop_back();
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
if (g.mapStates.size() == 1)
|
if (g.mapStates.isEmpty())
|
||||||
g.commandBuffer.setHistoryAutoSave(true);
|
g.commandBuffer.setHistoryAutoSave(true);
|
||||||
if (m_mode == ExMode || m_subsubmode == SearchSubSubMode)
|
if (m_mode == ExMode || m_subsubmode == SearchSubSubMode)
|
||||||
updateMiniBuffer(); // update cursor position on command line
|
updateMiniBuffer(); // update cursor position on command line
|
||||||
@@ -2889,20 +2888,20 @@ void FakeVimHandler::Private::updateMiniBuffer()
|
|||||||
int anchorPos = -1;
|
int anchorPos = -1;
|
||||||
MessageLevel messageLevel = MessageMode;
|
MessageLevel messageLevel = MessageMode;
|
||||||
|
|
||||||
if (g.mapStates.last().silent && g.currentMessageLevel < MessageInfo)
|
if (!g.mapStates.isEmpty() && g.mapStates.last().silent && g.currentMessageLevel < MessageInfo)
|
||||||
g.currentMessage.clear();
|
g.currentMessage.clear();
|
||||||
|
|
||||||
if (m_passing) {
|
if (m_passing) {
|
||||||
msg = _("PASSING");
|
msg = _("PASSING");
|
||||||
} else if (m_subsubmode == SearchSubSubMode) {
|
} else if (m_subsubmode == SearchSubSubMode) {
|
||||||
msg = g.searchBuffer.display();
|
msg = g.searchBuffer.display();
|
||||||
if (g.mapStates.size() == 1) {
|
if (g.mapStates.isEmpty()) {
|
||||||
cursorPos = g.searchBuffer.cursorPos() + 1;
|
cursorPos = g.searchBuffer.cursorPos() + 1;
|
||||||
anchorPos = g.searchBuffer.anchorPos() + 1;
|
anchorPos = g.searchBuffer.anchorPos() + 1;
|
||||||
}
|
}
|
||||||
} else if (m_mode == ExMode) {
|
} else if (m_mode == ExMode) {
|
||||||
msg = g.commandBuffer.display();
|
msg = g.commandBuffer.display();
|
||||||
if (g.mapStates.size() == 1) {
|
if (g.mapStates.isEmpty()) {
|
||||||
cursorPos = g.commandBuffer.cursorPos() + 1;
|
cursorPos = g.commandBuffer.cursorPos() + 1;
|
||||||
anchorPos = g.commandBuffer.anchorPos() + 1;
|
anchorPos = g.commandBuffer.anchorPos() + 1;
|
||||||
}
|
}
|
||||||
@@ -2910,7 +2909,7 @@ void FakeVimHandler::Private::updateMiniBuffer()
|
|||||||
msg = g.currentMessage;
|
msg = g.currentMessage;
|
||||||
g.currentMessage.clear();
|
g.currentMessage.clear();
|
||||||
messageLevel = g.currentMessageLevel;
|
messageLevel = g.currentMessageLevel;
|
||||||
} else if (g.mapStates.size() > 1 && !g.mapStates.last().silent) {
|
} else if (!g.mapStates.isEmpty() && !g.mapStates.last().silent) {
|
||||||
// Do not reset previous message when after running a mapped command.
|
// Do not reset previous message when after running a mapped command.
|
||||||
return;
|
return;
|
||||||
} else if (m_mode == CommandMode && !g.currentCommand.isEmpty() && hasConfig(ConfigShowCmd)) {
|
} else if (m_mode == CommandMode && !g.currentCommand.isEmpty() && hasConfig(ConfigShowCmd)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user