Skip to content

Commit b9cf6fc

Browse files
samiyacDevtools-frontend LUCI CQ
authored andcommitted
Make teaser text click-through
This will allow users to focus on the line by clicking on the teaser text Fixed: 480915672 Change-Id: Iaee55f62779ee793e26f0dac1b3f823d82bee59f Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7581258 Commit-Queue: Samiya Caur <samiyac@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
1 parent 9fc0129 commit b9cf6fc

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

front_end/ui/components/text_editor/AiCodeGenerationProvider.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,19 @@ function aiCodeGenerationTeaserExtension(teaser: PanelCommon.AiCodeGenerationTea
455455
// Required for mouse hover to propagate to the info button in teaser.
456456
return (event.target instanceof Node && teaser.contentElement.contains(event.target));
457457
},
458-
mousedown(event: MouseEvent): boolean {
459-
// Required for mouse click to propagate to the info tooltip in teaser.
460-
return (event.target instanceof Node && teaser.contentElement.contains(event.target));
458+
mousedown(event: MouseEvent, view: CodeMirror.EditorView): boolean {
459+
if (!(event.target instanceof Node) || !teaser.contentElement.contains(event.target)) {
460+
return false;
461+
}
462+
// On mouse click, move the cursor position to the end of the line.
463+
const cursorPosition = view.state.selection.main.head;
464+
const line = view.state.doc.lineAt(cursorPosition);
465+
if (cursorPosition !== line.to) {
466+
view.dispatch({selection: {anchor: line.to, head: line.to}});
467+
}
468+
// Explicitly focus the editor.
469+
view.focus();
470+
return true;
461471
},
462472
keydown(event: KeyboardEvent): boolean {
463473
if (!UI.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(event) ||

0 commit comments

Comments
 (0)