diff --git a/src/messages/textDocument_completion.cc b/src/messages/textDocument_completion.cc index b5a556ca..8a7394ef 100644 --- a/src/messages/textDocument_completion.cc +++ b/src/messages/textDocument_completion.cc @@ -537,9 +537,8 @@ void MessageHandler::textDocument_completion(CompletionParam ¶m, } std::string filter; - Position end_pos; - Position begin_pos = - wf->getCompletionPosition(param.position, &filter, &end_pos); + Position end_pos = param.position; + Position begin_pos = wf->getCompletionPosition(param.position, &filter); #if LLVM_VERSION_MAJOR < 8 ParseIncludeLineResult preprocess = ParseIncludeLine(buffer_line); diff --git a/src/messages/textDocument_signatureHelp.cc b/src/messages/textDocument_signatureHelp.cc index e5d5c0d7..8e8a7277 100644 --- a/src/messages/textDocument_signatureHelp.cc +++ b/src/messages/textDocument_signatureHelp.cc @@ -156,8 +156,7 @@ void MessageHandler::textDocument_signatureHelp( buffer_line = wf->buffer_lines[param.position.line]; { std::string filter; - Position end_pos; - begin_pos = wf->getCompletionPosition(param.position, &filter, &end_pos); + begin_pos = wf->getCompletionPosition(param.position, &filter); } SemaManager::OnComplete callback = diff --git a/src/working_files.cc b/src/working_files.cc index 09813ab1..f80f2105 100644 --- a/src/working_files.cc +++ b/src/working_files.cc @@ -339,18 +339,11 @@ std::optional WorkingFile::getIndexPosFromBufferPos(int line, int *column, index_lines, is_end); } -Position WorkingFile::getCompletionPosition(Position pos, std::string *filter, - Position *replace_end_pos) const { +Position WorkingFile::getCompletionPosition(Position pos, std::string *filter) const { int start = getOffsetForPosition(pos, buffer_content); int i = start; while (i > 0 && isIdentifierBody(buffer_content[i - 1])) --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); return getPositionForOffset(buffer_content, i); } diff --git a/src/working_files.hh b/src/working_files.hh index c7e51c7c..e8d1b462 100644 --- a/src/working_files.hh +++ b/src/working_files.hh @@ -52,8 +52,7 @@ struct WorkingFile { bool is_end); // Returns the stable completion position (it jumps back until there is a // non-alphanumeric character). - Position getCompletionPosition(Position pos, std::string *filter, - Position *replace_end_pos) const; + Position getCompletionPosition(Position pos, std::string *filter) const; private: // Compute index_to_buffer and buffer_to_index.