Skip to content

Commit 4014580

Browse files
committed
completion: Don't overwrite the following identifier (#749)
1 parent a2d2fd8 commit 4014580

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-15
lines changed

src/messages/textDocument_completion.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,8 @@ void MessageHandler::textDocument_completion(CompletionParam &param,
537537
}
538538

539539
std::string filter;
540-
Position end_pos;
541-
Position begin_pos =
542-
wf->getCompletionPosition(param.position, &filter, &end_pos);
540+
Position end_pos = param.position;
541+
Position begin_pos = wf->getCompletionPosition(param.position, &filter);
543542

544543
#if LLVM_VERSION_MAJOR < 8
545544
ParseIncludeLineResult preprocess = ParseIncludeLine(buffer_line);

src/messages/textDocument_signatureHelp.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ void MessageHandler::textDocument_signatureHelp(
156156
buffer_line = wf->buffer_lines[param.position.line];
157157
{
158158
std::string filter;
159-
Position end_pos;
160-
begin_pos = wf->getCompletionPosition(param.position, &filter, &end_pos);
159+
begin_pos = wf->getCompletionPosition(param.position, &filter);
161160
}
162161

163162
SemaManager::OnComplete callback =

src/working_files.cc

+1-8
Original file line numberDiff line numberDiff line change
@@ -339,18 +339,11 @@ std::optional<int> WorkingFile::getIndexPosFromBufferPos(int line, int *column,
339339
index_lines, is_end);
340340
}
341341

342-
Position WorkingFile::getCompletionPosition(Position pos, std::string *filter,
343-
Position *replace_end_pos) const {
342+
Position WorkingFile::getCompletionPosition(Position pos, std::string *filter) const {
344343
int start = getOffsetForPosition(pos, buffer_content);
345344
int i = start;
346345
while (i > 0 && isIdentifierBody(buffer_content[i - 1]))
347346
--i;
348-
349-
*replace_end_pos = pos;
350-
for (int i = start;
351-
i < buffer_content.size() && isIdentifierBody(buffer_content[i]); i++)
352-
replace_end_pos->character++;
353-
354347
*filter = buffer_content.substr(i, start - i);
355348
return getPositionForOffset(buffer_content, i);
356349
}

src/working_files.hh

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ struct WorkingFile {
5252
bool is_end);
5353
// Returns the stable completion position (it jumps back until there is a
5454
// non-alphanumeric character).
55-
Position getCompletionPosition(Position pos, std::string *filter,
56-
Position *replace_end_pos) const;
55+
Position getCompletionPosition(Position pos, std::string *filter) const;
5756

5857
private:
5958
// Compute index_to_buffer and buffer_to_index.

0 commit comments

Comments
 (0)