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