Skip to content

mac: signature help that knows which argument you are actually in - #237

Merged
GoKubar merged 1 commit into
mainfrom
agent/mac-signature-help
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/mac-signature-help

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

SignatureHelp was 210 lines beside a 2,500-line completion engine: it found the command, counted the argument groups you had closed, and emphasised that many groups into the pattern. Counting is wrong the moment an optional is involved, and the doc line said the same sentence whichever argument you were in.

1. Optional-argument awareness

The active group is matched by bracket kind, walking the pattern forward and skipping optionals you left out.

you type pattern before now
`\includegraphics{ }` *[keys]{file} [keys] ❌
`\includegraphics[width=2cm]{ }` *[keys]{file} {file} ✅
`\newcommand{\x}{ }` {\name}[n]{body} [n] ❌
`\begin{minipage}{ }` [pos][height][inner-pos]{width} —

A written [ the pattern does not list consumes no pattern group, and a trailing * belongs to the starred name rather than counting as an argument (\DeclareMathOperator*{).

2. Per-argument help

argumentHints says what each group means, so \rule's two identical {dimension}s read as the width and the height, and \includegraphics's [keys] lists the keys people actually reach for. It is keyed by command and indexed by the compiler inventory's own pattern, and testArgumentHintsMatchTheInventoryPatterns asserts one hint per group — the gate already earned its keep during development, catching \providecommand's [default] group and an \addtolength the compiler does not have.

3. Environments

\begin{tabular}{|l|cc|} is exactly where people need reminding what p{width} and | do, and it used to be refused outright ("the environment's own arguments are not documented here"). The compiler's inventory records environments by name, mode and description only — no argument shapes — so environmentSignatures supplies them: tabular/array/tabularx/longtable column specs, float [htbp] placement for figure/table/algorithm, minipage's three optionals, minted/lstlisting/tikzpicture option keys, thebibliography's widest label, enumitem keys for the list environments. Starred environments share their base signature.

\begin{|} is still \begin's own argument — there you are naming the environment, not passing it one.

Panel

The doc line shows the active argument's help, falling back to the command's documentation, and wraps to at most three lines with the panel sized to fit rather than truncating a sentence mid-word.

Tests

13 cases in SignatureHelpTests (6 new groups), including the two drift gates and the existing hosted-panel test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

`SignatureHelp` was 210 lines beside a 2,500-line completion engine: it found
the command, counted the argument groups you had closed, and emphasised that
many groups into the pattern. Counting is wrong as soon as an optional is
involved, and the doc line said the same sentence whichever argument you were
in. Three changes:

- **Optional-argument awareness.** The active group is now matched by bracket
  *kind*, skipping pattern optionals you left out. `\includegraphics{|}`
  emphasises `{file}`, not `[keys]`; `\newcommand{\x}{|}` is the body, not the
  arity; `\includegraphics[width=2cm]{|}` still lands on `{file}`. A written
  `[` the pattern does not list consumes no pattern group, and a trailing `*`
  belongs to the starred name rather than counting as an argument.

- **Per-argument help.** `argumentHints` says what each group means, so
  `\rule`'s two identical `{dimension}`s read as the width and the height, and
  `\includegraphics`'s `[keys]` lists the keys people actually want. It is
  keyed by command and indexed by the compiler inventory's own pattern, and
  `testArgumentHintsMatchTheInventoryPatterns` asserts one hint per group — the
  gate already earned its keep, catching `\providecommand`'s `[default]` group
  and a `\addtolength` the compiler does not have.

- **Environments.** `\begin{tabular}{|l|cc|}` is exactly where people need
  reminding what `p{width}` and `|` do, and it used to be refused outright.
  `environmentSignatures` supplies the shapes the inventory does not carry
  (it records environments by name, mode and description only): tabular and
  array column specs, float `[htbp]` placement, minipage's three optionals,
  minted/listings/TikZ option keys, thebibliography's widest label. Starred
  environments share their base signature. `\begin{|}` is still `\begin`'s own
  argument — there you are naming the environment, not passing it one.

The panel's doc line now shows the active argument's help, falling back to the
command's documentation, and wraps to at most three lines with the panel sized
to fit rather than truncating a sentence mid-word.

Implementation-Agent: claude-mac-lsp
Commit-Executor: claude-mac-lsp

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar force-pushed the agent/mac-signature-help branch from 1051374 to 044e2ae Compare September 14, 2026 00:50
@GoKubar
GoKubar marked this pull request as ready for review September 14, 2026 15:48
@GoKubar
GoKubar merged commit 3db68e6 into main Sep 14, 2026
20 checks passed
@GoKubar
GoKubar deleted the agent/mac-signature-help branch September 16, 2026 04: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.

1 participant