Bug 456701 - view.selection() returns ReferenceError: Range is not defined
Summary: view.selection() returns ReferenceError: Range is not defined
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: scripting (show other bugs)
Version: 22.04.3
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-14 05:18 UTC by loma
Modified: 2023-04-04 19:42 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description loma 2022-07-14 05:18:01 UTC
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
Comment 1 Christoph Cullmann 2022-07-17 17:52:18 UTC
Hmm, interesting, just looking at the code in KTextEditor I don't spot the obvious error.
Comment 2 Waqar Ahmed 2023-03-27 10:05:26 UTC
Can you share the script?
Comment 3 Bug Janitor Service 2023-03-28 21:23:02 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/530
Comment 4 Christoph Cullmann 2023-03-29 08:20:43 UTC
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
Comment 5 Waqar Ahmed 2023-04-04 19:42:14 UTC
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