From ae8cae5ba6b1239386bf7fa84f358fea93e72506 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Wed, 6 Dec 2017 17:00:19 -0800 Subject: [PATCH] Do not index files starting with git: --- src/message_handler.cc | 6 +++++- src/message_handler.h | 4 +++- src/messages/text_document_did_open.cc | 5 ++++- src/messages/text_document_did_save.cc | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/message_handler.cc b/src/message_handler.cc index a54a3c53..8bec99a5 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -146,4 +146,8 @@ void EmitSemanticHighlighting(QueryDatabase* db, for (auto& entry : grouped_symbols) out.params.symbols.push_back(entry.second); IpcManager::WriteStdout(IpcId::CqueryPublishSemanticHighlighting, out); -} \ No newline at end of file +} + +bool ShouldIgnoreFileForIndexing(const std::string& path) { + return StartsWith(path, "git:"); +} diff --git a/src/message_handler.h b/src/message_handler.h index dd3d149f..669c6a8b 100644 --- a/src/message_handler.h +++ b/src/message_handler.h @@ -77,4 +77,6 @@ void EmitInactiveLines(WorkingFile* working_file, void EmitSemanticHighlighting(QueryDatabase* db, SemanticHighlightSymbolCache* semantic_cache, WorkingFile* working_file, - QueryFile* file); \ No newline at end of file + QueryFile* file); + +bool ShouldIgnoreFileForIndexing(const std::string& path); diff --git a/src/messages/text_document_did_open.cc b/src/messages/text_document_did_open.cc index 9ef63f2f..4534c61f 100644 --- a/src/messages/text_document_did_open.cc +++ b/src/messages/text_document_did_open.cc @@ -24,6 +24,9 @@ struct TextDocumentDidOpenHandler Timer time; std::string path = request->params.textDocument.uri.GetPath(); + if (ShouldIgnoreFileForIndexing(path)) + return; + WorkingFile* working_file = working_files->OnOpen(request->params.textDocument); optional cached_file_contents = @@ -54,4 +57,4 @@ struct TextDocumentDidOpenHandler } }; REGISTER_MESSAGE_HANDLER(TextDocumentDidOpenHandler); -} // namespace \ No newline at end of file +} // namespace diff --git a/src/messages/text_document_did_save.cc b/src/messages/text_document_did_save.cc index 466c8d63..0b081f75 100644 --- a/src/messages/text_document_did_save.cc +++ b/src/messages/text_document_did_save.cc @@ -22,6 +22,9 @@ struct TextDocumentDidSaveHandler : BaseMessageHandler { void Run(Ipc_TextDocumentDidSave* request) override { std::string path = request->params.textDocument.uri.GetPath(); + if (ShouldIgnoreFileForIndexing(path)) + return; + // Send out an index request, and copy the current buffer state so we // can update the cached index contents when the index is done. // @@ -43,4 +46,4 @@ struct TextDocumentDidSaveHandler } }; REGISTER_MESSAGE_HANDLER(TextDocumentDidSaveHandler); -} // namespace \ No newline at end of file +} // namespace