Commit 5a0a61bf authored by Lukas Holecek's avatar Lukas Holecek Committed by hjk

FakeVim: Update file path and global marks

Update file path and global marks if file in project is renamed.

Update file path on "Save as...".

Task-number: QTCREATORBUG-12810
Change-Id: Ia2361e8f65a7a494e339d96c8b4610af4ab38edb
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 76caf841
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
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