From 2a4211ff98aa57d6c05fe2affbd306cf5eb225e2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Nov 2026 14:30:52 +0000 Subject: [PATCH 1/2] Initial plan From 9aa5aa3da7c7883efd1d4e358c918af126a3c239 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Nov 2026 14:35:38 +0000 Subject: [PATCH 2/2] editor: copy line on gutter double-click Co-authored-by: parmsam <40672605+parmsam@users.noreply.github.com> --- src/editor/index.ts | 13 +++++++++++-- src/editor/results.ts | 7 +++++++ tests/e2e/editor.spec.ts | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/editor/index.ts b/src/editor/index.ts index 2188fb4..7966be1 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -16,6 +16,7 @@ import { completion } from './completion'; import { explorable, interactiveNumbers, nextChoice } from './interactive'; import type { LineResult } from '../engine'; import { + copyLine, copyCurrentResult, engineSettings, results, @@ -74,6 +75,14 @@ export function createEditor({ const gutter = new Compartment(); let showLineNumbers = false; let currentSettings = settings; + const lineNumberGutter = () => + lineNumbers({ + domEventHandlers: { + dblclick(view, line) { + return copyLine(view, view.state.doc.lineAt(line.from).number); + }, + }, + }); const readOnlyExtensions = (on: boolean, explore = false) => [ EditorState.readOnly.of(on), EditorView.editable.of(!on), @@ -131,7 +140,7 @@ export function createEditor({ interactiveNumbers, reckonTheme, readOnly.of(readOnlyExtensions(ro, explore)), - gutter.of(showLineNumbers ? lineNumbers() : []), + gutter.of(showLineNumbers ? lineNumberGutter() : []), EditorView.updateListener.of((update) => { const userEdit = !update.state.readOnly && @@ -173,7 +182,7 @@ export function createEditor({ }, setLineNumbers(on) { showLineNumbers = on; - view.dispatch({ effects: gutter.reconfigure(on ? lineNumbers() : []) }); + view.dispatch({ effects: gutter.reconfigure(on ? lineNumberGutter() : []) }); }, setSettings(next) { currentSettings = { ...currentSettings, ...next }; diff --git a/src/editor/results.ts b/src/editor/results.ts index 773b710..e861751 100644 --- a/src/editor/results.ts +++ b/src/editor/results.ts @@ -472,6 +472,13 @@ export function copyCurrentResult(view: EditorView): boolean { return true; } +/** Copies the source text of a line. */ +export function copyLine(view: EditorView, line: number): boolean { + if (line < 1 || line > view.state.doc.lines) return false; + void copyResult(view, view.state.doc.line(line).text); + return true; +} + /** Announces the current line's result to screen readers. */ const liveRegion = ViewPlugin.fromClass( class { diff --git a/tests/e2e/editor.spec.ts b/tests/e2e/editor.spec.ts index 09df038..dee3fc6 100644 --- a/tests/e2e/editor.spec.ts +++ b/tests/e2e/editor.spec.ts @@ -61,6 +61,26 @@ test('clicking a result copies it', async ({ page, context, browserName }) => { expect(await page.evaluate(() => navigator.clipboard.readText())).toBe('3,000'); }); +test('double-clicking a line number copies the line', async ({ + page, + context, + browserName, + isMobile, +}) => { + test.skip(isMobile, 'desktop only'); + test.skip(browserName !== 'chromium', 'clipboard permissions are Chromium-only'); + await context.grantPermissions(['clipboard-read', 'clipboard-write']); + await page.goto('./'); + await page.getByRole('button', { name: 'Settings' }).click(); + await page.getByLabel('Show line numbers').check(); + await page.getByRole('button', { name: 'Done' }).click(); + await setNote(page, 'rent = $1,200\nrent × 12'); + + await page.locator('.cm-lineNumbers .cm-gutterElement', { hasText: /^2$/ }).dblclick(); + await expect(page.locator('#toast')).toHaveText('Copied rent × 12'); + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe('rent × 12'); +}); + test('converts units and currencies with live rates', async ({ page }) => { await page.goto('./'); await setNote(page, '5 km in miles\n$30 in EUR\n0.01 BTC in USD');