fix: Edit file tool take only absolute or relative path to file

This commit is contained in:
Petr Mironychev
2025-11-27 01:53:27 +01:00
parent 9b0ae98f02
commit 627a821115
4 changed files with 37 additions and 20 deletions

View File

@ -70,4 +70,18 @@ QString ProjectUtils::findFileInProject(const QString &filename)
return QString();
}
QString ProjectUtils::getProjectRoot()
{
QList<ProjectExplorer::Project *> projects = ProjectExplorer::ProjectManager::projects();
if (!projects.isEmpty()) {
auto project = projects.first();
if (project) {
return project->projectDirectory().toFSPathString();
}
}
return QString();
}
} // namespace QodeAssist::Context

View File

@ -52,6 +52,16 @@ public:
* @return Absolute file path if found, empty string otherwise
*/
static QString findFileInProject(const QString &filename);
/**
* @brief Get the project root directory
*
* Returns the root directory of the first open project.
* If multiple projects are open, returns the first one.
*
* @return Absolute path to project root, or empty string if no project is open
*/
static QString getProjectRoot();
};
} // namespace QodeAssist::Context