Skip to content

Let an include find its lines by regexp or Go symbol - #339

Merged
gdey merged 1 commit into
mainfrom
claude/project-thread-wszv0g
Nov 23, 2026
Merged

gdey merged 1 commit into
mainfrom
claude/project-thread-wszv0g

Conversation

@gdey

@gdey gdey commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Requested by j · project thread

Steps 1–3 of docs/spilled-output/design.md: the include window attributes and Go symbol=. out=file (steps 4 onward) follows in later PRs.

What changes

  • match="re" starts the window at the first line matching a Go regexp. before=N adds lines above, and lines=N or until="re" ends it. Without either, the window runs to the end of the file.
  • symbol=Name shows a Go func, a method (T.Method or (*T).Method), a type, a const or a var, with its doc comment. It is found with go/parser, so there are no new dependencies. comment=false drops the comment. Grouped consts and vars show only their own lines. When several definitions share the name, the first is used and mdsh warns. Other languages give a no-match warning for now (tier 2 is a later step).
  • Pairing rules are parse errors: match= and symbol= can't go with each other or with from=/to=, lines= can't go with until=/to=, and nth= is reserved.
  • No match: the block is left empty and the run doesn't fail. mdsh warns on stderr (mdsh: d.md: warning: line 3: include: no line of b.log matches "^FAIL"), mdsh-gui shows a no match badge, and the TUI shows a note.
  • Numbering starts at the window's first line in printing, the TUI, mdsh-gui (Result.FirstLine and Cell.FirstLine) and the PDF gutter.
  • mdsh-gui: a windowed include is labelled by how it finds its lines (match "^--- FAIL", 1 before, 5 lines). It has no range grips, because those only move from=/to=, and SetIncludeRange refuses it. The whole-file dialog marks the window.
  • lines= now means one thing on an include and another on a textbox, so the language server's and the editor's attribute lookups take the block kind into account (doc.LookupAttrFor).
  • Docs: README, spec, cheatsheet, site docs, examples/include.md (now with a match/until and a Go symbol example), and a CHANGELOG entry with a screenshot.

Screenshots

mdsh-gui (--serve, light): a log window from the first --- FAIL, numbered from line 42; a Go method by symbol=; and a match that found nothing.

include windows

The dark scheme and the whole-file dialog are in the project files under include-windows/.

Testing

  • go test ./... passes. TestStressScales failed once under full-suite load, then passed 3/3 when run on its own.
  • New tests: run.TestWindow (incl. CRLF and no final newline), TestWindowSymbol, TestIncludeWindow, doc.TestInclude cases, notebook.TestIncludeWindowCell, cmd/mdsh.TestIncludeNoMatch.
  • The frontend type-checks (tsc showed no errors in the changed files). The cmd/mdsh-gui vendor copy and web/bundle are regenerated.
  • Not run here: the generated bindings check (go generate needs GTK, which isn't in this container). I edited models.ts by hand to match what the generator emits, and CI's bindings check will confirm it.

Generated by Claude Code

An include block could only pick lines by number, so its window slid
off the right lines whenever the file changed above them. This is
steps 1 to 3 of docs/spilled-output/design.md, the part that is useful
on its own before out=file:

- match="re" starts at the first line matching a Go regexp; before=N
  adds lines above, lines=N or until="re" ends the window.
- symbol=Name shows a Go func, method (T.Method or (*T).Method), type,
  const or var with its doc comment, found with go/parser;
  comment=false drops the comment. Grouped consts and vars are their
  own lines. Other languages are a no-match warning for now.
- match= and symbol= exclude from= and to=, lines= excludes until=,
  and nth= is reserved, all as parse errors.
- A window that finds nothing is empty, with a warning on stderr, a
  "no match" badge in mdsh-gui and a note in the TUI; it doesn't fail
  the run.
- Numbering starts at the window's first line everywhere: printing,
  the TUI, mdsh-gui (Result.FirstLine) and the PDF gutter.
- mdsh-gui labels a windowed include by how it finds its lines and
  drops the range grips, which only move from= and to=.
- lines= now means one thing on an include and another on a textbox,
  so attribute lookups for the language server and the editor's help
  take the block kind into account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W9mexoiqFA4n1PYQWSzMDS
@gdey gdey self-assigned this Nov 23, 2026
@gdey
gdey merged commit 78a2a20 into main Nov 23, 2026
6 checks passed
@gdey
gdey deleted the claude/project-thread-wszv0g branch November 23, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants