AI Assistant: Check for selection before request for suggestions

Change-Id: I12207d9a9fcfea0b868c5d1c2fe5e2f7c6578f37
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Lukasz Papierkowski
2024-07-24 17:45:36 +02:00
committed by lie
parent b8dbcf3c9c
commit 2e7358f0a4

View File

@@ -189,6 +189,17 @@ local function sendRequest(request)
end end
local function requestSuggestions() local function requestSuggestions()
local main_cursor = TextEditor.currentEditor():cursor():mainCursor()
if main_cursor == nil then
print("No cursor found")
return
end
if(main_cursor:hasSelection()) then
print("Ignoring requestSuggestions() due to cursor selection")
return
end
local request_msg = buildRequest() local request_msg = buildRequest()
if(request_msg == nil) then if(request_msg == nil) then
print("requestSuggestions() failed to build request message") print("requestSuggestions() failed to build request message")