LUA: Add hasSuggestionLocked() method to TextEditor and clenaup

Change-Id: Iff0c1af586b69c930c55327f70a513ef94a5f879
Reviewed-by: Artur Twardy
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Lukasz Papierkowski
2024-09-24 18:16:29 +02:00
committed by lie
parent ad7ea80c07
commit fd0f8dc897
2 changed files with 9 additions and 20 deletions

View File

@@ -149,16 +149,6 @@ void setupTextEditorModule()
return TextEditor::BaseTextEditor::currentTextEditor();
};
result["currentSuggestion"] = []() -> TextEditor::CyclicSuggestion * {
if (const auto *textEditor = TextEditor::BaseTextEditor::currentTextEditor()) {
if (const TextEditor::TextEditorWidget *widget = textEditor->editorWidget())
return dynamic_cast<TextEditor::CyclicSuggestion *>(widget->currentSuggestion());
}
return nullptr;
};
result.new_usertype<TextEditor::CyclicSuggestion>("CyclicSuggestion", sol::no_constructor);
result.new_usertype<MultiTextCursor>(
"MultiTextCursor",
sol::no_constructor,
@@ -249,6 +239,11 @@ void setupTextEditorModule()
[](const TextEditorPtr &textEditor) {
QTC_ASSERT(textEditor, throw sol::error("TextEditor is not valid"));
return textEditor->editorWidget()->multiTextCursor();
},
"hasLockedSuggestion",
[](const TextEditorPtr &textEditor) {
QTC_ASSERT(textEditor, throw sol::error("TextEditor is not valid"));
return textEditor->editorWidget()->suggestionVisible();
});
result.new_usertype<TextEditor::TextSuggestion::Data>(

View File

@@ -60,13 +60,6 @@ local Suggestion = {}
---@return Suggestion suggestion The created suggestion.
function Suggestion:create(startLine, startCharacter, endLine, endCharacter, text) end
---@class CyclicSuggestion
local CyclicSuggestion = {}
---@return boolean True if the suggestion is locked, false otherwise.
---Suggestion is locked when the user selects it and already started applying it partially.
function CyclicSuggestion:isLocked() end
---@class TextDocument
local TextDocument = {}
@@ -106,12 +99,13 @@ function TextEditor:cursor() end
---@param position integer The position in the document where the widget should appear.
function TextEditor:addFloatingWidget(widget, position) end
---Checks if the current suggestion is locked. The suggestion is locked when the user can use it.
---@return boolean True if the suggestion is locked, false otherwise.
function TextEditor:hasLockedSuggestion() end
---Returns the current editor or nil.
---@return TextEditor|nil editor The currently active editor or nil if there is none.
function textEditor.currentEditor() end
---Returns the current suggestion of the current editor if available.
---@return CyclicSuggestion|nil suggestion The current suggestion if available. Otherwise nil.
function textEditor.currentSuggestion() end
return textEditor