mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +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;
 | 
			
		||||
  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);
 | 
			
		||||
 | 
			
		||||
@ -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 =
 | 
			
		||||
 | 
			
		||||
@ -339,18 +339,11 @@ std::optional<int> 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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user