@@ -76,9 +76,9 @@ bool CompareLsCompletionItem(const lsCompletionItem& lhs,
7676 return lhs.skip_ < rhs.skip_ ;
7777 if (lhs.priority_ != rhs.priority_ )
7878 return lhs.priority_ < rhs.priority_ ;
79- if (lhs.filterText . length () != rhs.filterText . length ())
80- return lhs.filterText . length () < rhs.filterText . length ();
81- return lhs.filterText < rhs.filterText ;
79+ if (lhs.filterText -> length () != rhs.filterText -> length ())
80+ return lhs.filterText -> length () < rhs.filterText -> length ();
81+ return * lhs.filterText < * rhs.filterText ;
8282}
8383
8484template <typename T>
@@ -121,7 +121,7 @@ void FilterAndSortCompletionResponse(
121121
122122 auto & items = complete_response->result .items ;
123123
124- if (!enable) {
124+ if (!enable || complete_text. empty () ) {
125125 // Just set the |sortText| to be the priority and return.
126126 char buf[16 ];
127127 for (auto & item : items)
@@ -130,17 +130,15 @@ void FilterAndSortCompletionResponse(
130130 }
131131
132132 // Make sure all items have |filterText| set, code that follow needs it.
133- for (auto & item : items) {
134- if (item.filterText . empty ()) {
133+ for (auto & item : items)
134+ if (! item.filterText )
135135 item.filterText = item.label ;
136- }
137- }
138136
139137 // If the text doesn't start with underscore,
140138 // remove all candidates that start with underscore.
141- if (!complete_text. empty () && complete_text[0 ] != ' _' ) {
139+ if (complete_text[0 ] != ' _' ) {
142140 auto filter = [](const lsCompletionItem& item) {
143- return item.filterText [0 ] == ' _' ;
141+ return (* item.filterText ) [0 ] == ' _' ;
144142 };
145143 items.erase (std::remove_if (items.begin (), items.end (), filter),
146144 items.end ());
@@ -150,7 +148,7 @@ void FilterAndSortCompletionResponse(
150148 bool found = false ;
151149 for (auto & item : items) {
152150 std::tie (item.found_ , item.skip_ ) =
153- SubsequenceCountSkip (complete_text, item.filterText );
151+ SubsequenceCountSkip (complete_text, * item.filterText );
154152 found = found || item.found_ ;
155153 }
156154
@@ -179,10 +177,12 @@ void FilterAndSortCompletionResponse(
179177 for (size_t i = 0 ; i < items.size (); ++i)
180178 items[i].sortText = tofixedbase64 (i, buf);
181179
182- // If there are too many results...
183- const size_t kMaxResultSize = 100u ;
184- if (items.size () > kMaxResultSize )
185- items.resize (kMaxResultSize );
180+ // FIXME
181+ // The trigger behivour of vscode is puzzling.
182+ // So maybe it's not feasible to cut out any results.
183+ // const size_t kMaxResultSize = 100u;
184+ // if (items.size() > kMaxResultSize)
185+ // items.resize(kMaxResultSize);
186186}
187187
188188struct TextDocumentCompletionHandler : MessageHandler {
@@ -224,8 +224,8 @@ struct TextDocumentCompletionHandler : MessageHandler {
224224 std::string character = *request->params .context ->triggerCharacter ;
225225 char preceding_index = request->params .position .character - 2 ;
226226
227- // If the character is '"' or '< ', make sure that the line starts with '#'.
228- if (character == " \" " || character == " <" ) {
227+ // If the character is '"', '<' or '/ ', make sure that the line starts with '#'.
228+ if (character == " \" " || character == " <" || character == " / " ) {
229229 size_t i = 0 ;
230230 while (i < buffer_line.size () && isspace (buffer_line[i]))
231231 ++i;
0 commit comments