gui: fix coordinate mapping for prompt textarea double-click

The MouseArea (chordArea) is a sibling of the ScrollView containing
promptInput, so mouse.x/y are relative to the parent Item, not the
TextArea. Map coordinates via mapToItem before calling positionAt.
This commit is contained in:
Levi Neely 2026-10-08 17:49:53 +02:00
parent 7cfd472193
commit 840723de3b
2 changed files with 8 additions and 3 deletions

View File

@ -151,6 +151,8 @@ qt_add_resources(ollie-gui "gui"
gui/ChatBlockDelegate.qml
gui/SessionTree.qml
gui/ChatPane.qml
gui/TextSelection.js
gui/ollie.svg
)
# --- Install ---

View File

@ -488,8 +488,10 @@ Item {
onDoubleClicked: function(mouse) {
if (mouse.button === Qt.LeftButton) {
if (!TextSelection.selectBracketPair(promptInput, mouse.x, mouse.y)) {
TextSelection.selectWordAt(promptInput, mouse.x, mouse.y)
// Map coordinates from chordArea to promptInput
var mappedPos = chordArea.mapToItem(promptInput, mouse.x, mouse.y)
if (!TextSelection.selectBracketPair(promptInput, mappedPos.x, mappedPos.y)) {
TextSelection.selectWordAt(promptInput, mappedPos.x, mappedPos.y)
}
mouse.accepted = true
}
@ -543,7 +545,8 @@ Item {
if (sel && sel.trim() !== "") {
plumber.plumb(sel.trim(), sessionCwd())
} else {
var pos = promptInput.positionAt(mouse.x, mouse.y)
var mappedPos = chordArea.mapToItem(promptInput, mouse.x, mouse.y)
var pos = promptInput.positionAt(mappedPos.x, mappedPos.y)
var word = wordAtCursor(promptInput, pos)
if (word) plumber.plumb(word, sessionCwd())
}