diff --git a/ChatView/ChatRootView.cpp b/ChatView/ChatRootView.cpp index a0cba81..c8ab0c1 100644 --- a/ChatView/ChatRootView.cpp +++ b/ChatView/ChatRootView.cpp @@ -510,7 +510,7 @@ void ChatRootView::onAppendLinkFileFromEditor(Core::IEditor *editor) { if (auto document = editor->document(); document && isSyncOpenFiles()) { QString filePath = document->filePath().toFSPathString(); - if (!m_linkedFiles.contains(filePath)) { + if (!m_linkedFiles.contains(filePath) && !shouldIgnoreFileForAttach(document->filePath())) { m_linkedFiles.append(filePath); emit linkedFilesChanged(); } @@ -537,4 +537,19 @@ void ChatRootView::setRecentFilePath(const QString &filePath) } } +bool ChatRootView::shouldIgnoreFileForAttach(const Utils::FilePath &filePath) +{ + auto project = ProjectExplorer::ProjectManager::projectForFile(filePath); + if (project + && m_clientInterface->contextManager() + ->ignoreManager() + ->shouldIgnore(filePath.toFSPathString(), project)) { + LOG_MESSAGE(QString("Ignoring file for attachment due to .qodeassistignore: %1") + .arg(filePath.toFSPathString())); + return true; + } + + return false; +} + } // namespace QodeAssist::Chat diff --git a/ChatView/ChatRootView.hpp b/ChatView/ChatRootView.hpp index 911e481..16a83e4 100644 --- a/ChatView/ChatRootView.hpp +++ b/ChatView/ChatRootView.hpp @@ -78,6 +78,7 @@ public: QString chatFileName() const; void setRecentFilePath(const QString &filePath); + bool shouldIgnoreFileForAttach(const Utils::FilePath &filePath); public slots: void sendMessage(const QString &message); diff --git a/context/IgnoreManager.cpp b/context/IgnoreManager.cpp index a4bd250..ae332da 100644 --- a/context/IgnoreManager.cpp +++ b/context/IgnoreManager.cpp @@ -37,24 +37,11 @@ IgnoreManager::IgnoreManager(QObject *parent) { auto projectManager = ProjectExplorer::ProjectManager::instance(); if (projectManager) { - connect( - projectManager, - &ProjectExplorer::ProjectManager::projectAdded, - this, - &IgnoreManager::reloadIgnorePatterns); - connect( projectManager, &ProjectExplorer::ProjectManager::projectRemoved, this, &IgnoreManager::removeIgnorePatterns); - - const QList projects = projectManager->projects(); - for (ProjectExplorer::Project *project : projects) { - if (project) { - reloadIgnorePatterns(project); - } - } } connect(