[education/rkward] /: Move some of the completion string handling to the frontend. This fixes problems with chained completions containing more than one operator.
Thomas Friedrichsmeier
null at kde.org
Wed Oct 5 20:55:28 BST 2022
Git commit c0500a5ca0c112fe97fe0ad90b12b6f996d78a4f by Thomas Friedrichsmeier.
Committed on 05/10/2022 at 19:54.
Pushed by tfry into branch 'master'.
Move some of the completion string handling to the frontend. This fixes problems with chained completions containing more than one operator.
M +1 -1 VERSION.cmake
M +1 -1 rkward/rbackend/rpackages/rkward/DESCRIPTION
M +3 -3 rkward/rbackend/rpackages/rkward/R/rk.completion-functions.R
M +12 -3 rkward/windows/rkcodecompletion.cpp
https://invent.kde.org/education/rkward/commit/c0500a5ca0c112fe97fe0ad90b12b6f996d78a4f
diff --git a/VERSION.cmake b/VERSION.cmake
index b7e80c59..f16e7fe4 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -1,3 +1,3 @@
# DO NOT CHANGE THIS FILE MANUALLY!
# It will be overwritten by scripts/set_dist_version.sh
-SET(RKVERSION_NUMBER 0.7.4z+0.7.5+devel4)
+SET(RKVERSION_NUMBER 0.7.4z+0.7.5+devel5)
diff --git a/rkward/rbackend/rpackages/rkward/DESCRIPTION b/rkward/rbackend/rpackages/rkward/DESCRIPTION
index 21c5d866..abc86bbb 100755
--- a/rkward/rbackend/rpackages/rkward/DESCRIPTION
+++ b/rkward/rbackend/rpackages/rkward/DESCRIPTION
@@ -18,7 +18,7 @@ Authors at R: c(person(given="Thomas", family="Friedrichsmeier",
role=c("aut")), person(family="the RKWard team",
email="rkward-devel at kde.org", role=c("cre","aut")))
Version: 0.7.5
-Date: 2022-07-18
+Date: 2022-10-05
RoxygenNote: 7.1.2
Collate:
'base_overrides.R'
diff --git a/rkward/rbackend/rpackages/rkward/R/rk.completion-functions.R b/rkward/rbackend/rpackages/rkward/R/rk.completion-functions.R
index f401a376..4f54daee 100644
--- a/rkward/rbackend/rpackages/rkward/R/rk.completion-functions.R
+++ b/rkward/rbackend/rpackages/rkward/R/rk.completion-functions.R
@@ -26,7 +26,7 @@
utils:::.assignStart(1)
utils:::.assignEnd(nchar(fragment) + nchar(type))
utils:::.completeToken()
- sub(paste0("^", fragment, ifelse(type == "$", "\\$", type)),"", utils:::.retrieveCompletions())
+ utils:::.retrieveCompletions()
} else if (type == "::" || type == ":::") {
utils::rc.settings(ops = FALSE, ns=TRUE, args = FALSE, dots = FALSE, func = FALSE, ipck = FALSE, S3 = FALSE, data = FALSE, help = FALSE, argdb = FALSE, fuzzy = FALSE, quotes = FALSE, files = FALSE)
utils:::.assignLinebuffer(paste0(fragment, type))
@@ -34,7 +34,7 @@
utils:::.assignStart(1)
utils:::.assignEnd(nchar(fragment) + nchar(type))
utils:::.completeToken()
- sub(paste0("^", fragment, type),"", utils:::.retrieveCompletions())
+ utils:::.retrieveCompletions()
} else if (type == "?") {
utils::rc.settings(ops = FALSE, ns=FALSE, args = FALSE, dots = FALSE, func = FALSE, ipck = FALSE, S3 = FALSE, data = FALSE, help = TRUE, argdb = FALSE, fuzzy = FALSE, quotes = FALSE, files = FALSE)
utils:::.assignLinebuffer(paste0(type, fragment))
@@ -42,6 +42,6 @@
utils:::.assignStart(1)
utils:::.assignEnd(nchar(fragment) + nchar(type))
utils:::.completeToken()
- sub("^\\?","", utils:::.retrieveCompletions())
+ utils:::.retrieveCompletions()
}
}
diff --git a/rkward/windows/rkcodecompletion.cpp b/rkward/windows/rkcodecompletion.cpp
index cf57be07..5aaa3282 100644
--- a/rkward/windows/rkcodecompletion.cpp
+++ b/rkward/windows/rkcodecompletion.cpp
@@ -582,7 +582,7 @@ void RKCodeCompletionModel::updateCompletionList(const QString& symbol, bool is_
rcompletions->update("?", symbol, symbol, shortnames);
} else if (objectpath.size() > 1) {
QString op = objectpath.at(objectpath.size() - 1 - objectpath.size() % 2);
- QString start = objectpath.at(objectpath.size() - 2 - objectpath.size() % 2);
+ QString start = objectpath.mid(0, objectpath.size() - 1 - objectpath.size() % 2).join("");
if (op == "$" || op == "@") {
rcompletions->update(op, start, objectpath.size() % 2 ? objectpath.last() : QString(), shortnames);
}
@@ -1035,8 +1035,17 @@ void RKDynamicCompletionsAddition::doUpdateFromR() {
return;
}
if (command->getDataType() == RCommand::StringVector) {
- QStringList nargs;
- current_raw_resultlist = command->stringVector();
+ QStringList res = command->stringVector();
+ current_raw_resultlist.clear();
+ // we used to do the subsitution below in R, but that proved challenging, as fragments would often contain symbols with a special meaning in regexps (importantly "$").
+ QString input;
+ if (mode() == "?") input = mode();
+ else if (mode() != "funargs") input = fragment() + mode();
+ for (int i = 0; i < res.size(); ++i) {
+ auto it = res[i];
+ if (it.startsWith(input)) current_raw_resultlist.append(it.right(it.length() - input.length()));
+ else RK_DEBUG(COMMANDEDITOR, DL_INFO, "got malformed completion %s", qPrintable(it));
+ }
} else {
RK_ASSERT(false);
}
More information about the rkward-tracker
mailing list