Restore include completion on #

This commit is contained in:
Jacob Dufault 2018-03-19 19:50:22 -07:00
parent 6d42b40319
commit 3f5e34ef20

View File

@ -115,7 +115,7 @@ ParseIncludeLineResult ParseIncludeLine(const std::string& line) {
"(.*)"); // [7]: suffix after quote char "(.*)"); // [7]: suffix after quote char
std::smatch match; std::smatch match;
bool ok = std::regex_match(line, match, pattern); bool ok = std::regex_match(line, match, pattern);
std::string text = match[6].str(); std::string text = match[3].str() + match[6].str();
return {ok, text, match}; return {ok, text, match};
} }
@ -298,33 +298,30 @@ struct TextDocumentCompletionHandler : MessageHandler {
Out_TextDocumentComplete out; Out_TextDocumentComplete out;
out.id = request->id; out.id = request->id;
std::string text = result.match[3]; {
if (std::string_view("include").compare(0, text.size(), text) == 0) { std::unique_lock<std::mutex> lock(
{ include_complete->completion_items_mutex, std::defer_lock);
std::unique_lock<std::mutex> lock( if (include_complete->is_scanning)
include_complete->completion_items_mutex, std::defer_lock); lock.lock();
if (include_complete->is_scanning) std::string quote = result.match[5];
lock.lock(); for (auto& item : include_complete->completion_items)
std::string quote = result.match[5]; if (quote.empty() || quote == (item.use_angle_brackets_ ? "<" : "\""))
for (auto& item : include_complete->completion_items) out.result.items.push_back(item);
if (quote.empty() || quote == (item.use_angle_brackets_ ? "<" : "\"")) }
out.result.items.push_back(item);
}
// Needed by |FilterAndSortCompletionResponse|. // Needed by |FilterAndSortCompletionResponse|.
for (lsCompletionItem& item : out.result.items) for (lsCompletionItem& item : out.result.items)
item.filterText = item.label; item.filterText = item.label;
FilterAndSortCompletionResponse(&out, result.pattern, FilterAndSortCompletionResponse(&out, result.pattern,
config->completion.filterAndSort); config->completion.filterAndSort);
DecorateIncludePaths(result.match, &out.result.items); DecorateIncludePaths(result.match, &out.result.items);
for (lsCompletionItem& item : out.result.items) { for (lsCompletionItem& item : out.result.items) {
item.textEdit->range.start.line = request->params.position.line; item.textEdit->range.start.line = request->params.position.line;
item.textEdit->range.start.character = 0; item.textEdit->range.start.character = 0;
item.textEdit->range.end.line = request->params.position.line; item.textEdit->range.end.line = request->params.position.line;
item.textEdit->range.end.character = (int)buffer_line.size(); item.textEdit->range.end.character = (int)buffer_line.size();
}
} }
QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out); QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out);