Fix .kateproject generation: per-repo, not workspace-level
Kate project plugin needs .kateproject in each repo subdir for project switching to work. A workspace-level .kateproject makes Kate treat the whole workspace as one project, breaking repo switching.
This commit is contained in:
parent
c520e46cf5
commit
fe4c618780
|
|
@ -2322,14 +2322,16 @@ void GitPlusPlusView::detectWorkspace()
|
|||
ws.sync();
|
||||
}
|
||||
|
||||
// Auto-generate .kateproject if missing
|
||||
QString kateProjectFile = m_workspaceDir + QStringLiteral("/.kateproject");
|
||||
if (!QFileInfo::exists(kateProjectFile)) {
|
||||
QFile kp(kateProjectFile);
|
||||
if (kp.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QString wsName = QFileInfo(m_workspaceDir).fileName();
|
||||
kp.write("{\n \"name\": \"" + wsName.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n");
|
||||
kp.close();
|
||||
// Auto-generate .kateproject in each repo subdir that lacks one
|
||||
for (const auto &repoPath : qAsConst(m_workspaceRepos)) {
|
||||
QString kateProjectFile = repoPath + QStringLiteral("/.kateproject");
|
||||
if (!QFileInfo::exists(kateProjectFile)) {
|
||||
QFile kp(kateProjectFile);
|
||||
if (kp.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QString repoName = QFileInfo(repoPath).fileName();
|
||||
kp.write("{\n \"name\": \"" + repoName.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n");
|
||||
kp.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2556,11 +2558,17 @@ void GitPlusPlusView::createWorkspace()
|
|||
}
|
||||
}
|
||||
|
||||
// 6. Write .kateproject in new workspace
|
||||
QFile kateProject(newWsPath + QStringLiteral("/.kateproject"));
|
||||
if (kateProject.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
kateProject.write("{\n \"name\": \"" + name.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n");
|
||||
kateProject.close();
|
||||
// 6. Write .kateproject in each repo subdir
|
||||
for (const auto &repoName : sourceRepos) {
|
||||
QString targetRepoPath = newWsPath + QLatin1Char('/') + repoName;
|
||||
QString kpFile = targetRepoPath + QStringLiteral("/.kateproject");
|
||||
if (QFileInfo::exists(targetRepoPath) && !QFileInfo::exists(kpFile)) {
|
||||
QFile kp(kpFile);
|
||||
if (kp.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
kp.write("{\n \"name\": \"" + repoName.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n");
|
||||
kp.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failed == 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue