Skip to content

Commit 9f87e9d

Browse files
committed
const qualify CompletionFinder::writecompletions
1 parent e8a6e36 commit 9f87e9d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/engine/interface/console.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class CompletionFinder
6262
void complete(char *s, size_t maxlen, const char *cmdprefix);
6363

6464
//print to a stream f the listcompletions in the completions filesval
65-
void writecompletions(std::fstream& f);
65+
void writecompletions(std::fstream& f) const;
6666

6767
private:
6868

@@ -224,7 +224,7 @@ void CompletionFinder::complete(char *s, size_t maxlen, const char *cmdprefix)
224224
}
225225

226226
//print to a stream f the listcompletions in the completions filesval
227-
void CompletionFinder::writecompletions(std::fstream& f)
227+
void CompletionFinder::writecompletions(std::fstream& f) const
228228
{
229229
std::vector<std::string> cmds;
230230
for(auto &[k, v] : completions)
@@ -237,12 +237,13 @@ void CompletionFinder::writecompletions(std::fstream& f)
237237
std::sort(cmds.begin(), cmds.end());
238238
for(std::string &k : cmds)
239239
{
240-
FilesVal *v = completions[k.c_str()];
241-
if(!v)
240+
auto itr = completions.find(k.c_str());
241+
if(itr == completions.end())
242242
{
243243
conoutf("could not write completion");
244244
return;
245245
}
246+
const FilesVal *v = (*itr).second;
246247
if(v->type==Files_List)
247248
{
248249
if(validateblock(v->dir.c_str()))

0 commit comments

Comments
 (0)