From d583dde17bb114395580609ee97a3032ec8ff727 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 3 Sep 2021 17:14:54 +0200 Subject: ClangCodeModel: Force clangd restart on external changes Neither we nor clangd can afford to watch all source files, which means that after e.g. a branch switch we can easily end up in an inconsistent state. We alleviate this problem by restarting clangd if at least one open file was changed externally. Change-Id: I7e0d14835e3afbd7a64c3233614f2161282dddc0 Reviewed-by: David Schulz --- src/plugins/texteditor/textdocument.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/plugins/texteditor/textdocument.cpp') diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index a8f56f5b40..a705d1e90a 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -106,6 +106,7 @@ public: QScopedPointer m_formatter; int m_autoSaveRevision = -1; + bool m_silentReload = false; TextMarks m_marksCache; // Marks not owned Utils::Guard m_modificationChangedGuard; @@ -426,6 +427,13 @@ QAction *TextDocument::createDiffAgainstCurrentFileAction( return diffAction; } +#ifdef WITH_TESTS +void TextDocument::setSilentReload() +{ + d->m_silentReload = true; +} +#endif + void TextDocument::triggerPendingUpdates() { if (d->m_fontSettingsNeedsApply) @@ -707,6 +715,13 @@ void TextDocument::setFilePath(const Utils::FilePath &newName) IDocument::setFilePath(newName.absoluteFilePath()); } +IDocument::ReloadBehavior TextDocument::reloadBehavior(ChangeTrigger state, ChangeType type) const +{ + if (d->m_silentReload) + return IDocument::BehaviorSilent; + return BaseTextDocument::reloadBehavior(state, type); +} + bool TextDocument::isModified() const { return d->m_document.isModified(); -- cgit v1.2.1