Commit fae09d2e authored by Marcell Fülöp's avatar Marcell Fülöp Committed by Christoph Cullmann
Browse files

Make sure ViewSpace config groups are preserved on exit in a session

when their document does not have any views (because their tab was never activated).

BUG 433581
parent da0c8e21
...@@ -330,8 +330,12 @@ void KateSessionManager::saveSessionTo(KConfig *sc) const ...@@ -330,8 +330,12 @@ void KateSessionManager::saveSessionTo(KConfig *sc) const
{ {
// Clear the session file to avoid to accumulate outdated entries // Clear the session file to avoid to accumulate outdated entries
for (const auto &group : sc->groupList()) { for (const auto &group : sc->groupList()) {
// Don't delete groups for loaded documents that have
// VeiwSpace config in session but do not have any views.
if (!isViewLessDocumentViewSpaceGroup(group)) {
sc->deleteGroup(group); sc->deleteGroup(group);
} }
}
// save plugin configs and which plugins to load // save plugin configs and which plugins to load
KateApp::self()->pluginManager()->writeConfig(sc); KateApp::self()->pluginManager()->writeConfig(sc);
...@@ -639,4 +643,21 @@ void KateSessionManager::updateJumpListActions(const QStringList &sessionList) ...@@ -639,4 +643,21 @@ void KateSessionManager::updateJumpListActions(const QStringList &sessionList)
df->desktopGroup().writeXdgListEntry("Actions", newActions); df->desktopGroup().writeXdgListEntry("Actions", newActions);
} }
bool KateSessionManager::isViewLessDocumentViewSpaceGroup(const QString &group) {
if (!group.startsWith(QStringLiteral("MainWindow"))) return false;
QRegExp re(QStringLiteral("^MainWindow\\d+-ViewSpace\\s\\d+\\s(.*)$"));
if (group.indexOf(re) > -1) {
QUrl url(re.cap(1));
auto *docMan = KateApp::self()->documentManager();
auto *doc = docMan->findDocument(url);
bool anonSession = KateApp::self()->sessionManager()->activeSession()->isAnonymous();
if (doc && doc->views().empty() && docMan->documentList().contains(doc) && !anonSession) {
return true;
}
}
return false;
}
// END KateSessionManager // END KateSessionManager
...@@ -217,6 +217,19 @@ private: ...@@ -217,6 +217,19 @@ private:
*/ */
void updateJumpListActions(const QStringList &sessionList); void updateJumpListActions(const QStringList &sessionList);
/**
* Given a config group name, determines if the group represents
* a session ViewSpace group (i.e. "MainWindowN-ViewSpace N [doc url]")
* and, if so,
* - returns TRUE if the document referred to has no views
* and the session is not anonymous;
* - returns FALSE otherwise.
*
* A document does not have a view when it is opened in a named session
* until its tab is activated.
*/
static bool isViewLessDocumentViewSpaceGroup(const QString &group) ;
private: private:
/** /**
* absolute path to dir in home dir where to store the sessions * absolute path to dir in home dir where to store the sessions
......
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