mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 00:25:07 +00:00
Don't include system header files for #include "
(#i"
) completion
This commit is contained in:
parent
4d23e9fa10
commit
b9c3af0be9
@ -90,8 +90,7 @@ int FuzzyMatcher::Match(std::string_view text) {
|
||||
for (int i = 0; i < n; i++)
|
||||
low_text[i] = ::tolower(text[i]);
|
||||
CalculateRoles(text, text_role, &text_set);
|
||||
dp[0][0][0] = 0;
|
||||
dp[0][0][1] = kMinScore * 2;
|
||||
dp[0][0][0] = dp[0][0][1] = 0;
|
||||
for (int j = 0; j < n; j++) {
|
||||
dp[0][j + 1][0] = dp[0][j][0] + MissScore(j, false);
|
||||
dp[0][j + 1][1] = kMinScore * 2;
|
||||
@ -143,6 +142,10 @@ TEST_SUITE("fuzzy_match") {
|
||||
}
|
||||
|
||||
TEST_CASE("test") {
|
||||
FuzzyMatcher fuzzy("");
|
||||
CHECK(fuzzy.Match("") == 0);
|
||||
CHECK(fuzzy.Match("aaa") < 0);
|
||||
|
||||
// case
|
||||
Ranks("monad", {"monad", "Monad", "mONAD"});
|
||||
// initials
|
||||
|
@ -98,7 +98,7 @@ void DecorateIncludePaths(const std::smatch& match,
|
||||
|
||||
struct ParseIncludeLineResult {
|
||||
bool ok;
|
||||
std::string text; // include the "include" part
|
||||
std::string pattern;
|
||||
std::smatch match;
|
||||
};
|
||||
|
||||
@ -115,7 +115,7 @@ ParseIncludeLineResult ParseIncludeLine(const std::string& line) {
|
||||
"(.*)"); // [7]: suffix after quote char
|
||||
std::smatch match;
|
||||
bool ok = std::regex_match(line, match, pattern);
|
||||
std::string text = match[3].str() + match[6].str();
|
||||
std::string text = match[6].str();
|
||||
return {ok, text, match};
|
||||
}
|
||||
|
||||
@ -298,22 +298,24 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
||||
Out_TextDocumentComplete out;
|
||||
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);
|
||||
if (include_complete->is_scanning)
|
||||
lock.lock();
|
||||
out.result.items.assign(include_complete->completion_items.begin(),
|
||||
include_complete->completion_items.end());
|
||||
if (lock)
|
||||
lock.unlock();
|
||||
std::string quote = result.match[5];
|
||||
for (auto& item : include_complete->completion_items)
|
||||
if (quote.empty() || quote == (item.use_angle_brackets_ ? "<" : "\""))
|
||||
out.result.items.push_back(item);
|
||||
}
|
||||
|
||||
// Needed by |FilterAndSortCompletionResponse|.
|
||||
for (lsCompletionItem& item : out.result.items)
|
||||
item.filterText = "include" + item.label;
|
||||
item.filterText = item.label;
|
||||
|
||||
FilterAndSortCompletionResponse(&out, result.text,
|
||||
FilterAndSortCompletionResponse(&out, result.pattern,
|
||||
config->completion.filterAndSort);
|
||||
DecorateIncludePaths(result.match, &out.result.items);
|
||||
|
||||
@ -323,6 +325,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
||||
item.textEdit->range.end.line = request->params.position.line;
|
||||
item.textEdit->range.end.character = (int)buffer_line.size();
|
||||
}
|
||||
}
|
||||
|
||||
QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user