Double-clicking the Frontmatter, a script or a style row opens it in the code editor - #28
Merged
Conversation
…dit its code A row holding code now opens it in the floating code editor on double-click, the same editor Enter and the "Edit code" button open. Element rows still do nothing and component rows still open their file. The row passes its own id instead of relying on the selection: its click has only just asked for the selection, which still names the previous row when the double-click lands. Enter, "Edit code" and the double-click now share one pure rule, codeWindowFor, so they cannot disagree on the title or the language. It matches the tag case-insensitively, as the parser does, so a <STYLE> block opens as CSS instead of being labelled JavaScript. test/navigator-open-code.js covers the rule and the navigator rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the Navigator, double-clicking a row that holds code now opens it in the floating code editor. This is the same editor that Enter and the "Edit code" button already open. Element rows still do nothing on double-click, and component rows still open their file.
The row passes its own id because the click that selects it has only just requested the selection. When the double-click fires,
selectedNodestill points to the previous row.Enter, "Edit code" and the double-click now all go through one pure rule, so they always agree on the title and language:
src/ +├── codeWindowTarget.ts # codeWindowFor(subject): frontmatter | <style> | <script> → editor, else undefined ├── App.tsx # openCodeWindow / openCodeWindowById call codeWindowFor └── panels/ ├── StructurePanel.tsx # Frontmatter row: onDoubleClick → onOpenCode('frontmatter') └── StructureTree.tsx # raw rows: onDoubleClick → onOpenCode(id)A side effect:
codeWindowFormatches the tag name case-insensitively, as the parser does. A<STYLE>block used to open labelled as JavaScript and now opens as CSS.Evidence
New test:
test/navigator-open-code.js(npm run test:navigatoropencode).npm test→ 153/153 test commands.npm run dev: Frontmatter,<style>and<script>open in the editor, components still open their file, and Enter and "Edit code" work as before.Merge Danger
Door: two-way
The change only adds a handler and extracts an existing rule, with no data or file-format changes. Reverting the commit fully restores the old behaviour.
Blast Radius: small
<style>and<script>rows in the Navigator.codeWindowFor. Their output is unchanged, except that a capitalised<STYLE>now opens as CSS.codeWindowForasserts that a raw node is astyleor ascript, which is the parser'sRAW_ELEMENTSinvariant. A new raw element added to the parser later would have to be added toRAW_CODE_LANGUAGESas well.🤖 Generated with Claude Code