[rkward] rkward: In completion offers, provide full name, if and only if object name is masked in the search path.
Thomas Friedrichsmeier
null at kde.org
Sat Jan 12 10:20:23 GMT 2019
Git commit f8d7cd62e7ba960737d8d6f363031d7566b20812 by Thomas Friedrichsmeier.
Committed on 12/01/2019 at 10:19.
Pushed by tfry into branch 'master'.
In completion offers, provide full name, if and only if object name is masked in the search path.
M +17 -2 rkward/core/robjectlist.cpp
M +1 -6 rkward/rkconsole.cpp
M +1 -1 rkward/windows/rkcommandeditorwindow.cpp
https://commits.kde.org/rkward/f8d7cd62e7ba960737d8d6f363031d7566b20812
diff --git a/rkward/core/robjectlist.cpp b/rkward/core/robjectlist.cpp
index deb95b84..c71c7022 100644
--- a/rkward/core/robjectlist.cpp
+++ b/rkward/core/robjectlist.cpp
@@ -261,8 +261,23 @@ RObject *RObjectList::findObjects (const QStringList &path, RObjectSearchMap *ma
RObject *found = getGlobalEnv ()->findObjects (path, matches, "$");
if (found && !matches) return found;
for (int i = 0; i < childmap.size (); ++i) {
- found = childmap[i]->findObjects (path, matches, "$");
- if (found && !matches) return found;
+ if (!matches) {
+ found = childmap[i]->findObjects (path, 0, "$");
+ if (found) return found;
+ } else {
+ RObjectSearchMap pmatches;
+ childmap[i]->findObjects (path, &pmatches, "$");
+ // For matches in environments on the search path:
+ // - If the name is *not* masked (yet), return the plain name.
+ // - If the name *is* masked, return the full qualitfied name.
+ for (RObjectSearchMap::const_iterator it = pmatches.constBegin (); it != pmatches.constEnd (); ++it) {
+ if (matches->contains (it.key ())) {
+ matches->insert (it.value ()->getFullName (), it.value ());
+ } else {
+ matches->insert (it.key (), it.value ());
+ }
+ }
+ }
}
return 0;
}
diff --git a/rkward/rkconsole.cpp b/rkward/rkconsole.cpp
index 363f80d2..368eca95 100644
--- a/rkward/rkconsole.cpp
+++ b/rkward/rkconsole.cpp
@@ -492,12 +492,7 @@ void RKConsole::doTabCompletion () {
} else if (!current_symbol.isEmpty ()) {
RObject::RObjectSearchMap map;
RObjectList::getObjectList ()->findObjectsMatching (current_symbol, &map);
- QStringList completions;
- for (RObject::RObjectSearchMap::const_iterator i = map.constBegin (); i != map.constEnd(); ++i) {
- completions.append (i.value ()->getBaseName ());
- }
-
- if (doTabCompletionHelper (current_line_num, current_line, word_start, word_end, completions)) return;
+ if (doTabCompletionHelper (current_line_num, current_line, word_start, word_end, map.keys ())) return;
}
// no completion was possible
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index ba9c37d0..30a5a3b6 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -1296,7 +1296,7 @@ void RKCodeCompletionModel::updateCompletionList (const QString& symbol) {
// in case objects are removed while the completion mode is active.
for (RObject::RObjectSearchMap::const_iterator it = map.constBegin (); it != map.constEnd (); ++it) {
icons.append (RKStandardIcons::iconForObject (it.value ()));
- names.append (it.value ()->getBaseName ());
+ names.append (it.key ());
}
setRowCount (count);
More information about the rkward-tracker
mailing list