Skip to content

fix: show sub-code command completions when typing a trailing dot - #156

Merged
misiekhardcore merged 1 commit into
mainfrom
feat/dot-subcode-completion-support
Jun 2, 2026
Merged

misiekhardcore merged 1 commit into
mainfrom
feat/dot-subcode-completion-support

Conversation

@misiekhardcore

Copy link
Copy Markdown
Contributor

Context

Typing a trailing dot while entering a G-code sub-code (e.g. G05.) caused the completion context detector to drop out of command mode and switch into axis-parameter mode. The user would see axis parameters for the base command (G05) instead of the expected sub-code completions (G05.1, G05.2, G05.3). Continuing to type a digit (e.g. G05.1) restored the correct behaviour, but the dot keystroke itself broke the flow.

Root cause: checkCommandContext used the regex \.\d+ which requires at least one digit after the dot. G05. has no digit yet, so the regex failed to match, and the code fell through to checkParameterContext which matched only the base code G05.

Fix: relaxed the regex to \.\d* (zero or more digits), so a trailing dot is recognised as an in-progress command prefix and keeps the user in command completion mode.

Acceptance Criteria

  • Typing G05. triggers command completions filtered to G05.1, G05.2, G05.3 — not axis parameters.
  • Typing G05.1 (with a digit) still triggers command completions filtered to G05.1.
  • Typing G05.1 (with a space) correctly switches to parameter completions for G05.1 (X, Y, I, J).
  • Typing G05.3 (with a space) returns no parameters, since G05.3 (NURBS Execute) takes none.
  • All 1393 existing unit tests continue to pass.

Testing

Four new unit tests added to CompletionProvider.test.ts — one for each AC bullet above. All pass after the one-line regex change.

When a user typed a trailing dot in a G-code sub-code prefix (e.g. G05.),
the completion context detector's regex required at least one digit after
the dot (\.\d+), so G05. fell through to parameter context and showed
axis parameters for G05 instead of sub-code completions for G05.1/G05.2/G05.3.

Relaxed the regex to \.\d* so a trailing dot is treated as a command prefix,
keeping the user in command completion mode until they select or type the digit.
@misiekhardcore
misiekhardcore merged commit 4324201 into main Jun 2, 2026
7 of 8 checks passed
@misiekhardcore
misiekhardcore deleted the feat/dot-subcode-completion-support branch June 2, 2026 20:13
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