mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 18:00:26 +00:00
Only set insertTextFormat to Snippet when we have placeholders
This commit is contained in:
parent
dbeb4eb511
commit
2bd4671ddd
@ -135,6 +135,7 @@ void BuildDetailString(CXCompletionString completion_string,
|
||||
std::string& label,
|
||||
std::string& detail,
|
||||
std::string& insert,
|
||||
lsInsertTextFormat& format,
|
||||
std::vector<std::string>* parameters,
|
||||
bool include_snippets) {
|
||||
int num_chunks = clang_getNumCompletionChunks(completion_string);
|
||||
@ -146,7 +147,7 @@ void BuildDetailString(CXCompletionString completion_string,
|
||||
case CXCompletionChunk_Optional: {
|
||||
CXCompletionString nested =
|
||||
clang_getCompletionChunkCompletionString(completion_string, i);
|
||||
BuildDetailString(nested, label, detail, insert, parameters,
|
||||
BuildDetailString(nested, label, detail, insert, format, parameters,
|
||||
include_snippets);
|
||||
break;
|
||||
}
|
||||
@ -160,6 +161,7 @@ void BuildDetailString(CXCompletionString completion_string,
|
||||
if (include_snippets) {
|
||||
insert +=
|
||||
"${" + std::to_string(parameters->size()) + ":" + text + "}";
|
||||
format = lsInsertTextFormat::Snippet;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -204,6 +206,7 @@ void BuildDetailString(CXCompletionString completion_string,
|
||||
// Put cursor between parentheses if snippets are not enabled
|
||||
if (!include_snippets) {
|
||||
insert += "$1";
|
||||
format = lsInsertTextFormat::Snippet;
|
||||
}
|
||||
break;
|
||||
case CXCompletionChunk_RightParen:
|
||||
@ -260,8 +263,6 @@ void BuildDetailString(CXCompletionString completion_string,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
insert += "$0";
|
||||
}
|
||||
|
||||
void TryEnsureDocumentParsed(ClangCompleteManager* manager,
|
||||
@ -420,8 +421,11 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
|
||||
BuildDetailString(
|
||||
result.CompletionString, ls_completion_item.label,
|
||||
ls_completion_item.detail, ls_completion_item.insertText,
|
||||
ls_completion_item.insertTextFormat,
|
||||
&ls_completion_item.parameters_,
|
||||
completion_manager->config_->enableSnippetInsertion);
|
||||
if (ls_completion_item.insertTextFormat == lsInsertTextFormat::Snippet)
|
||||
ls_completion_item.insertText += "$0";
|
||||
|
||||
ls_completion_item.documentation = ToString(
|
||||
clang_getCompletionBriefComment(result.CompletionString));
|
||||
|
@ -360,7 +360,7 @@ struct lsCompletionItem {
|
||||
|
||||
// The format of the insert text. The format applies to both the `insertText`
|
||||
// property and the `newText` property of a provided `textEdit`.
|
||||
lsInsertTextFormat insertTextFormat = lsInsertTextFormat::Snippet;
|
||||
lsInsertTextFormat insertTextFormat = lsInsertTextFormat::PlainText;
|
||||
|
||||
// An edit which is applied to a document when selecting this completion. When
|
||||
// an edit is provided the value of `insertText` is ignored.
|
||||
|
Loading…
Reference in New Issue
Block a user