[education/rkward] rkward: Also fix command selection near end of script files
Thomas Friedrichsmeier
null at kde.org
Tue May 27 21:53:38 BST 2025
Git commit d5ef827230a104a23964d1b265223821ed1b6cbf by Thomas Friedrichsmeier.
Committed on 27/05/2025 at 20:53.
Pushed by tfry into branch 'master'.
Also fix command selection near end of script files
M +1 -1 rkward/autotests/data/script1.R
M +5 -0 rkward/autotests/rkparsedscript_test.cpp
M +1 -1 rkward/windows/rkcodenavigation.cpp
https://invent.kde.org/education/rkward/-/commit/d5ef827230a104a23964d1b265223821ed1b6cbf
diff --git a/rkward/autotests/data/script1.R b/rkward/autotests/data/script1.R
index 78568c154..415b52bb6 100644
--- a/rkward/autotests/data/script1.R
+++ b/rkward/autotests/data/script1.R
@@ -39,4 +39,4 @@ FunctionList <- list(
}, ddd, eee <- fff(ggg + hhh) + iii, jjj)
)
-symb.last
+symb.last # comment last, no newline at EOF
diff --git a/rkward/autotests/rkparsedscript_test.cpp b/rkward/autotests/rkparsedscript_test.cpp
index 1a51825d0..f92108bfe 100644
--- a/rkward/autotests/rkparsedscript_test.cpp
+++ b/rkward/autotests/rkparsedscript_test.cpp
@@ -163,6 +163,11 @@ class RKParsedScriptTest : public QObject {
ctx = moveAndCheck(ps.nextStatement(ctx), u"Symbol.x"_s);
ctx = moveAndCheck(ps.nextStatement(ctx), u"FunctionList"_s);
ctx = moveAndCheck(ps.nextStatement(ctx), u"symb.last"_s);
+ // verify that symbol at end of file can be selected, correctly
+ int posa = ps.getContext(ps.firstContextInStatement(ctx)).start;
+ int posb = ps.lastPositionInStatement(ctx);
+ QVERIFY(posb > posa);
+ QVERIFY(script.mid(posa).startsWith(u"symb.last"_s));
QVERIFY(!ps.nextStatement(ctx).valid());
ctx = ps.contextAtPos(script.indexOf(u"FunctionList"));
diff --git a/rkward/windows/rkcodenavigation.cpp b/rkward/windows/rkcodenavigation.cpp
index d026dc796..d7de0e77b 100644
--- a/rkward/windows/rkcodenavigation.cpp
+++ b/rkward/windows/rkcodenavigation.cpp
@@ -169,7 +169,7 @@ class RKCodeNavigationInternal : public QObject {
return KTextEditor::Cursor(l, pos + doc->lineLength(l) + 1);
}
}
- return KTextEditor::Cursor();
+ return doc->documentEnd(); // this may actually be hit in well-behaved code!
}
KTextEditor::View *view;
More information about the rkward-tracker
mailing list