mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-07 08:44:55 +00:00
Initialization Option: completion.overwriteFollowingIdentifier
Previously, ccls overwrites the identifier immediately following the cursor on completions. Some user does not want this behaviour. This commit introduces a new initialization option: completion.overwriteFollowingIdentifier, which allows customizing the said behaviour. fix #678.
This commit is contained in:
parent
a2d2fd8167
commit
af782dfa21
@ -166,6 +166,11 @@ struct Config {
|
|||||||
// that implement their own filtering and sorting logic.
|
// that implement their own filtering and sorting logic.
|
||||||
bool filterAndSort = true;
|
bool filterAndSort = true;
|
||||||
|
|
||||||
|
// Decides whether to overwrite the identifier following cursor.
|
||||||
|
// true -- overwrite the following identifier.
|
||||||
|
// false -- insert completion before the following identifier.
|
||||||
|
bool overwriteFollowingIdentifier = true;
|
||||||
|
|
||||||
struct Include {
|
struct Include {
|
||||||
// Regex patterns to match include completion candidates against. They
|
// Regex patterns to match include completion candidates against. They
|
||||||
// receive the absolute file path.
|
// receive the absolute file path.
|
||||||
@ -338,8 +343,8 @@ REFLECT_STRUCT(Config::CodeLens, localVariables);
|
|||||||
REFLECT_STRUCT(Config::Completion::Include, blacklist, maxPathSize,
|
REFLECT_STRUCT(Config::Completion::Include, blacklist, maxPathSize,
|
||||||
suffixWhitelist, whitelist);
|
suffixWhitelist, whitelist);
|
||||||
REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel,
|
REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel,
|
||||||
dropOldRequests, duplicateOptional, filterAndSort, include,
|
dropOldRequests, duplicateOptional, filterAndSort,
|
||||||
maxNum, placeholder);
|
overwriteFollowingIdentifier, include, maxNum, placeholder);
|
||||||
REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
|
REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
|
||||||
spellChecking, whitelist)
|
spellChecking, whitelist)
|
||||||
REFLECT_STRUCT(Config::Highlight, largeFileSize, lsRanges, blacklist, whitelist)
|
REFLECT_STRUCT(Config::Highlight, largeFileSize, lsRanges, blacklist, whitelist)
|
||||||
|
@ -347,9 +347,12 @@ Position WorkingFile::getCompletionPosition(Position pos, std::string *filter,
|
|||||||
--i;
|
--i;
|
||||||
|
|
||||||
*replace_end_pos = pos;
|
*replace_end_pos = pos;
|
||||||
for (int i = start;
|
if (g_config->completion.overwriteFollowingIdentifier) {
|
||||||
i < buffer_content.size() && isIdentifierBody(buffer_content[i]); i++)
|
// attempt to overwrite the following identifier
|
||||||
replace_end_pos->character++;
|
for (int i = start;
|
||||||
|
i < buffer_content.size() && isIdentifierBody(buffer_content[i]); i++)
|
||||||
|
replace_end_pos->character++;
|
||||||
|
}
|
||||||
|
|
||||||
*filter = buffer_content.substr(i, start - i);
|
*filter = buffer_content.substr(i, start - i);
|
||||||
return getPositionForOffset(buffer_content, i);
|
return getPositionForOffset(buffer_content, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user