diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 628c29fd37a..fb963cde7e6 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -320,6 +320,8 @@ public: const QString &fileName() const { return m_fileName; } + void setFileName(const QString &fileName) { m_fileName = fileName; } + private: CursorPosition m_position; QString m_fileName; @@ -8472,6 +8474,15 @@ void FakeVimHandler::disconnectFromEditor() d->m_plaintextedit = 0; } +void FakeVimHandler::updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName) +{ + for (int i = 0; i < Private::g.marks.size(); ++i) { + Mark &mark = Private::g.marks[i]; + if (mark.fileName() == oldFileName) + mark.setFileName(newFileName); + } +} + bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev) { #ifndef FAKEVIM_STANDALONE diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h index 68c0ceaff86..58189ce2e56 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -98,6 +98,8 @@ public: // call before widget is deleted void disconnectFromEditor(); + static void updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName); + public slots: void setCurrentFileName(const QString &fileName); QString currentFileName() const; diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index eb42a734c8e..3da6bcdc884 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -1003,6 +1003,10 @@ private slots: void editorOpened(Core::IEditor *); void editorAboutToClose(Core::IEditor *); + void allDocumentsRenamed(const QString &oldName, const QString &newName); + void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName); + void renameFileNameInEditors(const QString &oldName, const QString &newName); + void setUseFakeVim(const QVariant &value); void setUseFakeVimInternal(bool on); void quitFakeVim(); @@ -1222,6 +1226,11 @@ bool FakeVimPluginPrivate::initialize() connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), this, SLOT(editorOpened(Core::IEditor*))); + connect(DocumentManager::instance(), SIGNAL(allDocumentsRenamed(QString,QString)), + this, SLOT(allDocumentsRenamed(QString,QString))); + connect(DocumentManager::instance(), SIGNAL(documentRenamed(Core::IDocument*,QString,QString)), + this, SLOT(documentRenamed(Core::IDocument*,QString,QString))); + connect(theFakeVimSetting(ConfigUseFakeVim), SIGNAL(valueChanged(QVariant)), this, SLOT(setUseFakeVim(QVariant))); connect(theFakeVimSetting(ConfigReadVimRc), SIGNAL(valueChanged(QVariant)), @@ -1823,6 +1832,26 @@ void FakeVimPluginPrivate::editorAboutToClose(IEditor *editor) m_editorToHandler.remove(editor); } +void FakeVimPluginPrivate::allDocumentsRenamed(const QString &oldName, const QString &newName) +{ + renameFileNameInEditors(oldName, newName); + FakeVimHandler::updateGlobalMarksFilenames(oldName, newName); +} + +void FakeVimPluginPrivate::documentRenamed( + IDocument *, const QString &oldName, const QString &newName) +{ + renameFileNameInEditors(oldName, newName); +} + +void FakeVimPluginPrivate::renameFileNameInEditors(const QString &oldName, const QString &newName) +{ + foreach (FakeVimHandler *handler, m_editorToHandler.values()) { + if (handler->currentFileName() == oldName) + handler->setCurrentFileName(newName); + } +} + void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value) { //qDebug() << "SET USE FAKEVIM" << value;