From 226263f77c31b27feea36537d85b2ea2c36a5beb Mon Sep 17 00:00:00 2001 From: Le Tan Date: Fri, 21 Jul 2017 22:09:40 +0800 Subject: [PATCH] bug-fix: save wrong geometry state in single panel view --- src/utils/vvim.cpp | 5 ++++- src/vedit.h | 3 +++ src/vmainwindow.cpp | 4 ++++ src/vmdtab.cpp | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/utils/vvim.cpp b/src/utils/vvim.cpp index 8bfb2d98..2a39b1a4 100644 --- a/src/utils/vvim.cpp +++ b/src/utils/vvim.cpp @@ -1311,7 +1311,10 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos) case Qt::Key_Escape: { // Clear selection and enter normal mode. - clearSelection(); + bool ret = clearSelection(); + if (!ret && checkMode(VimMode::Normal)) { + emit m_editor->requestCloseFindReplaceDialog(); + } setMode(VimMode::Normal); break; diff --git a/src/vedit.h b/src/vedit.h index 8f78edee..d10f10e7 100644 --- a/src/vedit.h +++ b/src/vedit.h @@ -154,6 +154,9 @@ signals: // Selection changed by mouse. void selectionChangedByMouse(bool p_hasSelection); + // Request the edit tab to close find and replace dialog. + void requestCloseFindReplaceDialog(); + public slots: virtual void highlightCurrentLine(); diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index 0da2915a..7d876880 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -1538,6 +1538,10 @@ void VMainWindow::closeEvent(QCloseEvent *event) void VMainWindow::saveStateAndGeometry() { + // In one panel view, it will save the wrong state that the directory tree + // panel has a width of zero. + twoPanelView(); + vconfig.setMainWindowGeometry(saveGeometry()); vconfig.setMainWindowState(saveState()); vconfig.setToolsDockChecked(toolDock->isVisible()); diff --git a/src/vmdtab.cpp b/src/vmdtab.cpp index fd181596..2a02f799 100644 --- a/src/vmdtab.cpp +++ b/src/vmdtab.cpp @@ -323,6 +323,10 @@ void VMdTab::setupMarkdownEditor() this, &VEditTab::statusMessage); connect(m_editor, &VEdit::vimStatusUpdated, this, &VEditTab::vimStatusUpdated); + connect(m_editor, &VEdit::requestCloseFindReplaceDialog, + this, [this](){ + this->m_editArea->getFindReplaceDialog()->closeDialog(); + }); m_editor->reloadFile(); m_stacks->addWidget(m_editor);