mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
completion: Don't overwrite the following identifier (#749)
This commit is contained in:
parent
a2d2fd8167
commit
40145807d5
@ -537,9 +537,8 @@ void MessageHandler::textDocument_completion(CompletionParam ¶m,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string filter;
|
std::string filter;
|
||||||
Position end_pos;
|
Position end_pos = param.position;
|
||||||
Position begin_pos =
|
Position begin_pos = wf->getCompletionPosition(param.position, &filter);
|
||||||
wf->getCompletionPosition(param.position, &filter, &end_pos);
|
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR < 8
|
#if LLVM_VERSION_MAJOR < 8
|
||||||
ParseIncludeLineResult preprocess = ParseIncludeLine(buffer_line);
|
ParseIncludeLineResult preprocess = ParseIncludeLine(buffer_line);
|
||||||
|
@ -156,8 +156,7 @@ void MessageHandler::textDocument_signatureHelp(
|
|||||||
buffer_line = wf->buffer_lines[param.position.line];
|
buffer_line = wf->buffer_lines[param.position.line];
|
||||||
{
|
{
|
||||||
std::string filter;
|
std::string filter;
|
||||||
Position end_pos;
|
begin_pos = wf->getCompletionPosition(param.position, &filter);
|
||||||
begin_pos = wf->getCompletionPosition(param.position, &filter, &end_pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SemaManager::OnComplete callback =
|
SemaManager::OnComplete callback =
|
||||||
|
@ -339,18 +339,11 @@ std::optional<int> WorkingFile::getIndexPosFromBufferPos(int line, int *column,
|
|||||||
index_lines, is_end);
|
index_lines, is_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
Position WorkingFile::getCompletionPosition(Position pos, std::string *filter,
|
Position WorkingFile::getCompletionPosition(Position pos, std::string *filter) const {
|
||||||
Position *replace_end_pos) const {
|
|
||||||
int start = getOffsetForPosition(pos, buffer_content);
|
int start = getOffsetForPosition(pos, buffer_content);
|
||||||
int i = start;
|
int i = start;
|
||||||
while (i > 0 && isIdentifierBody(buffer_content[i - 1]))
|
while (i > 0 && isIdentifierBody(buffer_content[i - 1]))
|
||||||
--i;
|
--i;
|
||||||
|
|
||||||
*replace_end_pos = pos;
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,7 @@ struct WorkingFile {
|
|||||||
bool is_end);
|
bool is_end);
|
||||||
// Returns the stable completion position (it jumps back until there is a
|
// Returns the stable completion position (it jumps back until there is a
|
||||||
// non-alphanumeric character).
|
// non-alphanumeric character).
|
||||||
Position getCompletionPosition(Position pos, std::string *filter,
|
Position getCompletionPosition(Position pos, std::string *filter) const;
|
||||||
Position *replace_end_pos) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Compute index_to_buffer and buffer_to_index.
|
// Compute index_to_buffer and buffer_to_index.
|
||||||
|
Loading…
Reference in New Issue
Block a user