diff --git a/src/plugins/lua/bindings/texteditor.cpp b/src/plugins/lua/bindings/texteditor.cpp index 0a2c4603edf..9d6cac00025 100644 --- a/src/plugins/lua/bindings/texteditor.cpp +++ b/src/plugins/lua/bindings/texteditor.cpp @@ -176,7 +176,11 @@ void setupTextEditorModule() "columnNumber", &QTextCursor::columnNumber, "hasSelection", - &QTextCursor::hasSelection); + &QTextCursor::hasSelection, + "selectedText", + [](QTextCursor *cursor) { + return cursor->selectedText().replace(QChar::ParagraphSeparator, '\n'); + }); result.new_usertype( "TextEditor", diff --git a/src/plugins/lua/meta/texteditor.lua b/src/plugins/lua/meta/texteditor.lua index 2c3876eac01..84f240edbef 100644 --- a/src/plugins/lua/meta/texteditor.lua +++ b/src/plugins/lua/meta/texteditor.lua @@ -6,6 +6,9 @@ local textEditor = {} ---@field blockNumber integer The block (line) number of the cursor. ---@field columnNumber integer The column number of the cursor. local TextCursor = {} +---Returns the selected text of the cursor. +---@return string selectedText The selected text of the cursor. +function TextCursor:selectedText() end ---@class MultiTextCursor ---@field mainCursor TextCursor The main cursor.