From 6216eedbc96a641b1f0c2c8e24610fd219790674 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 5 Aug 2012 21:34:29 -0700 Subject: [PATCH] Removing "__" from completion strings --- cpp/ycm/CompletionData.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cpp/ycm/CompletionData.cpp b/cpp/ycm/CompletionData.cpp index 613b5af4..a84e6fea 100644 --- a/cpp/ycm/CompletionData.cpp +++ b/cpp/ycm/CompletionData.cpp @@ -18,6 +18,8 @@ #include "CompletionData.h" #include "standard.h" +#include + namespace { @@ -124,6 +126,18 @@ std::string OptionalChunkToString( CXCompletionString completion_string, return final_string; } + +// NOTE: this function accepts the text param by value on purpose; it internally +// needs a copy before processing the text so the copy might as well be made on +// the parameter BUT if this code is compiled in C++11 mode a move constructor +// can be called on the passed-in value. This is not possible if we accept the +// param by const ref. +std::string RemoveTwoUnderscores( std::string text ) +{ + boost::erase_all( text, "__" ); + return text; +} + } // unnamed namespace @@ -201,6 +215,15 @@ CompletionData::CompletionData( const CXCompletionResult &completion_result ) kind_ = CursorKindToVimKind( completion_result.CursorKind ); + // We remove any two consecutive underscores from the function definition + // since identifiers with them are ugly, compiler-reserved names. Functions + // from the standard library use parameter names like "__pos" and we want to + // show them as just "pos". This will never interfere with client code since + // ANY C++ identifier with two consecutive underscores in it is + // compiler-reserved. + everything_except_return_type_ = + RemoveTwoUnderscores( everything_except_return_type_ ); + detailed_info_.append( return_type_ ) .append( " " ) .append( everything_except_return_type_ )