fix: show sub-code command completions when typing a trailing dot - #156
Merged
Merged
Conversation
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.
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.
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:
checkCommandContextused 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 tocheckParameterContextwhich matched only the base codeG05.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
G05.triggers command completions filtered toG05.1,G05.2,G05.3— not axis parameters.G05.1(with a digit) still triggers command completions filtered toG05.1.G05.1(with a space) correctly switches to parameter completions forG05.1(X, Y, I, J).G05.3(with a space) returns no parameters, sinceG05.3(NURBS Execute) takes none.Testing
Four new unit tests added to
CompletionProvider.test.ts— one for each AC bullet above. All pass after the one-line regex change.