From 58fe609eeaf8049b70249af25ce2126b95850ab4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 21:14:37 +0000 Subject: [PATCH 1/4] Initial plan From 2ae13e23dd7f537ad87ab407682d88d6d19c59aa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 21:25:15 +0000 Subject: [PATCH 2/4] Remove CodeMirror dependency from live editor playground MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace 7 CodeMirror CDN imports with vanilla JS: - Input editor: CodeMirror EditorView →
@@ -259,7 +273,7 @@
Compiled YAML will appear here
- + From d8962cd26a1986479a95a5fb532b837040274761 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 21:58:22 +0000 Subject: [PATCH 3/4] fix: address review feedback on editor playground - Fix measureCharWidth font setting (was invalid cssText concat) - Cache getComputedStyle values, invalidate on resize - Throttle mousemove with requestAnimationFrame - Fix hideTooltip to clear existing timer before scheduling - Clamp tooltip left to min padding for narrow viewports - Append tooltip to document.body (avoids transform issues) - Use replaceChildren() instead of innerHTML='' - Use execCommand('insertText') for Tab to preserve undo - Add Shift-Tab dedent support - Fix Mod-Enter to set pendingCompile when compiler not ready - Add aria-labelledby to textarea for accessibility Agent-Logs-Url: https://github.com/github/gh-aw/sessions/96fa5b92-7f2f-4beb-8e80-e75a9885cb69 Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> --- docs/public/editor/editor.js | 32 ++++++++++++---- docs/public/editor/hover-tooltips.js | 56 ++++++++++++++++++++-------- docs/public/editor/index.html | 4 +- 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/docs/public/editor/editor.js b/docs/public/editor/editor.js index 3f48ce782bd..7d2de5970d8 100644 --- a/docs/public/editor/editor.js +++ b/docs/public/editor/editor.js @@ -88,20 +88,36 @@ const savedContent = localStorage.getItem(STORAGE_KEY); const initialContent = savedContent || DEFAULT_CONTENT; editorTextarea.value = initialContent; -// Tab inserts 2 spaces; Mod-Enter triggers compile +// Tab inserts 2 spaces (preserving undo); Shift-Tab dedents; Mod-Enter triggers compile editorTextarea.addEventListener('keydown', (e) => { - if (e.key === 'Tab') { + if (e.key === 'Tab' && !e.shiftKey) { + e.preventDefault(); + // execCommand preserves the browser undo stack + document.execCommand('insertText', false, ' '); + } + if (e.key === 'Tab' && e.shiftKey) { e.preventDefault(); const start = editorTextarea.selectionStart; - const end = editorTextarea.selectionEnd; const val = editorTextarea.value; - editorTextarea.value = val.substring(0, start) + ' ' + val.substring(end); - editorTextarea.selectionStart = editorTextarea.selectionEnd = start + 2; - editorTextarea.dispatchEvent(new Event('input')); + // Find the start of the current line + const lineStart = val.lastIndexOf('\n', start - 1) + 1; + const lineEnd = val.indexOf('\n', start); + const line = val.substring(lineStart, lineEnd === -1 ? val.length : lineEnd); + const spaces = line.match(/^ {1,2}/); + if (spaces) { + // Select the leading spaces and delete them via execCommand to preserve undo + editorTextarea.selectionStart = lineStart; + editorTextarea.selectionEnd = lineStart + spaces[0].length; + document.execCommand('delete', false); + } } if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') { e.preventDefault(); - doCompile(); + if (isReady) { + doCompile(); + } else { + pendingCompile = true; + } } }); @@ -117,7 +133,7 @@ editorTextarea.addEventListener('input', () => { }); // Attach hover tooltips to the textarea -attachHoverTooltips(editorTextarea, $('panelEditor')); +attachHoverTooltips(editorTextarea); // If restoring saved content, clear the dropdown since it may not match any sample if (savedContent) { diff --git a/docs/public/editor/hover-tooltips.js b/docs/public/editor/hover-tooltips.js index 899bfbbfe69..f147daef030 100644 --- a/docs/public/editor/hover-tooltips.js +++ b/docs/public/editor/hover-tooltips.js @@ -236,9 +236,8 @@ function measureCharWidth(textarea) { if (_charWidth !== null) return _charWidth; const span = document.createElement('span'); - span.style.cssText = - 'position:absolute;visibility:hidden;white-space:pre;' + - window.getComputedStyle(textarea).font; + span.style.cssText = 'position:absolute;visibility:hidden;white-space:pre;'; + span.style.font = window.getComputedStyle(textarea).font; span.textContent = 'M'; document.body.appendChild(span); _charWidth = span.getBoundingClientRect().width; @@ -253,15 +252,16 @@ function measureCharWidth(textarea) { /** * Attach hover-tooltip behaviour to a +
From eebdf18bafbe5134fddea3b8c9c26223b4df3869 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 21:59:53 +0000 Subject: [PATCH 4/4] fix: simplify tooltip clamping, preserve selection on dedent Agent-Logs-Url: https://github.com/github/gh-aw/sessions/96fa5b92-7f2f-4beb-8e80-e75a9885cb69 Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> --- docs/public/editor/editor.js | 9 ++++++++- docs/public/editor/hover-tooltips.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/public/editor/editor.js b/docs/public/editor/editor.js index 7d2de5970d8..f2dff90fb95 100644 --- a/docs/public/editor/editor.js +++ b/docs/public/editor/editor.js @@ -98,6 +98,7 @@ editorTextarea.addEventListener('keydown', (e) => { if (e.key === 'Tab' && e.shiftKey) { e.preventDefault(); const start = editorTextarea.selectionStart; + const end = editorTextarea.selectionEnd; const val = editorTextarea.value; // Find the start of the current line const lineStart = val.lastIndexOf('\n', start - 1) + 1; @@ -105,10 +106,16 @@ editorTextarea.addEventListener('keydown', (e) => { const line = val.substring(lineStart, lineEnd === -1 ? val.length : lineEnd); const spaces = line.match(/^ {1,2}/); if (spaces) { + const removed = spaces[0].length; // Select the leading spaces and delete them via execCommand to preserve undo editorTextarea.selectionStart = lineStart; - editorTextarea.selectionEnd = lineStart + spaces[0].length; + editorTextarea.selectionEnd = lineStart + removed; document.execCommand('delete', false); + // Restore adjusted selection + const newStart = Math.max(lineStart, start - removed); + const newEnd = Math.max(lineStart, end - removed); + editorTextarea.selectionStart = newStart; + editorTextarea.selectionEnd = newEnd; } } if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') { diff --git a/docs/public/editor/hover-tooltips.js b/docs/public/editor/hover-tooltips.js index f147daef030..f70d541a182 100644 --- a/docs/public/editor/hover-tooltips.js +++ b/docs/public/editor/hover-tooltips.js @@ -301,7 +301,7 @@ export function attachHoverTooltips(textarea) { if (top < 0) top = y + pad; const minLeft = pad; const maxLeft = window.innerWidth - tooltip.offsetWidth - pad; - left = Math.max(minLeft, Math.min(left, Math.max(minLeft, maxLeft))); + left = Math.max(minLeft, Math.min(left, maxLeft)); tooltip.style.left = left + 'px'; tooltip.style.top = top + 'px'; }