SUMMARY *** Returned range from view.selection() is always invalid even with valid text selection *** STEPS TO REPRODUCE 1. Create a script with calls to view.hasSelection(), view.selection() and view.selectedText() 2. Make a text selection in view 3. Execute the script OBSERVED RESULT view.hasSelection() returns True, view.selectedText() returns the text within selection range but view.selection() returns ReferenceError: Range is not defined EXPECTED RESULT view.selection() should return a valid range object with start cursor and end cursor of the selection SOFTWARE/OS VERSIONS Linux/KDE Plasma: ArchLinux (available in About System) KDE Plasma Version: 5.25.3 KDE Frameworks Version: Qt Version: ADDITIONAL INFORMATION
Hmm, interesting, just looking at the code in KTextEditor I don't spot the obvious error.
Can you share the script?
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/530
Git commit aad8b713f26858853052eb4f7eaa33682a7b7ad6 by Christoph Cullmann, on behalf of Waqar Ahmed. Committed on 29/03/2023 at 08:20. Pushed by cullmann into branch 'master'. Include range.js when initializing the engine Otherwise if one tries to use methods that return a range it results in an error. M +6 -1 src/script/katescript.cpp https://invent.kde.org/frameworks/ktexteditor/commit/aad8b713f26858853052eb4f7eaa33682a7b7ad6
Git commit 0b593672fe32b2e359e3fc10390ad4c97617b7d4 by Waqar Ahmed. Committed on 04/04/2023 at 18:55. Pushed by cullmann into branch 'kf5'. Include range.js when initializing the engine Otherwise if one tries to use methods that return a range it results in an error. M +6 -1 src/script/katescript.cpp https://invent.kde.org/frameworks/ktexteditor/commit/0b593672fe32b2e359e3fc10390ad4c97617b7d4