Browse Source

Language protocol: fixed autocomplete insertion when language server answers with incomplete insertText

merge-requests/382/head
eidheim 8 years ago
parent
commit
0897f09118
  1. 7
      src/source_language_protocol.cc

7
src/source_language_protocol.cc

@ -1225,7 +1225,12 @@ void Source::LanguageProtocolView::setup_autocomplete() {
auto detail=it->second.get<std::string>("detail", ""); auto detail=it->second.get<std::string>("detail", "");
auto documentation=it->second.get<std::string>("documentation", ""); auto documentation=it->second.get<std::string>("documentation", "");
auto insert=it->second.get<std::string>("insertText", ""); auto insert=it->second.get<std::string>("insertText", "");
if(insert.empty()) { if(!insert.empty()) { // In case ( is missing in insert but is present in label
auto pos=label.find('(');
if(pos!=std::string::npos && pos==insert.size() && pos+1<label.size() && label.back()==')' && insert.find('(')==std::string::npos)
insert+="(${1:"+label.substr(pos+1, label.size()-1-(pos+1))+"})";
}
else {
insert=label; insert=label;
auto kind=it->second.get<unsigned>("kind", 0); auto kind=it->second.get<unsigned>("kind", 0);
if(kind>=2 && kind<=3) { if(kind>=2 && kind<=3) {

Loading…
Cancel
Save