Skip to content

Fix common prefix completion issue#2146

Merged
msujew merged 1 commit into
mainfrom
msujew/fix-partial-completion
Apr 30, 2026
Merged

Fix common prefix completion issue#2146
msujew merged 1 commit into
mainfrom
msujew/fix-partial-completion

Conversation

@msujew
Copy link
Copy Markdown
Member

@msujew msujew commented Apr 30, 2026

Closes #1370

Simply updates our version of chevrotain-allstar to 0.4.2 which includes a fix for this. Also adds a test to ensure that we don't regress in the future.

@msujew msujew requested a review from cdietrich April 30, 2026 09:58
@msujew msujew merged commit fab8e57 into main Apr 30, 2026
4 checks passed
@msujew msujew deleted the msujew/fix-partial-completion branch April 30, 2026 10:17
@cdietrich
Copy link
Copy Markdown
Contributor

@msujew i just have the new version a try by overrding yarn resolution.
now we see a ton of new parse errors.
is this expected?

@msujew
Copy link
Copy Markdown
Member Author

msujew commented Apr 30, 2026

I'll have another look 👍

@cdietrich
Copy link
Copy Markdown
Contributor

we have the same pattern at some other places
but also our expressions break. but i could not nail that one yet

@cdietrich
Copy link
Copy Markdown
Contributor

expression reproducer model

  ensure someOtherNumber / 10  

and grammar

entry Model: items+=Stmt*;

  Stmt: 'ensure' expr=Additive;

  Additive infers Expression:                                                                                                                                                                                                     
      Multiplicative
      (({infer Add.left=current} '+' | {infer Sub.left=current} '-') right=Multiplicative)*;                                                                                                                                      
                                                            
  Multiplicative infers Expression:
      Primary
      (({infer Mul.left=current} '*' | {infer Div.left=current} '/') right=Primary)*;
                                                                                                                                                                                                                                  
  Primary infers Expression:
      RefExpression | NumberLiteral;                                                                                                                                                                                              
                                                            
  RefExpression:
      target=PathOrMetadataAccess;
                                                                                                                                                                                                                                  
  NumberLiteral:
      value=NUMBER;                                                                                                                                                                                                               
                                                            
  PathOrMetadataAccess returns string:
      PATH | MetadataAccess;

  // '/' inside PATH collides with '/' as division operator                                                                                                                                                                       
  PATH returns string:
      ID | (ID ('/' ID)* ':' ID);                                                                                                                                                                                                 
                                                            
  terminal MetadataAccess: /@[_a-zA-Z][\w_-]*/;                                                                                                                                                                                   
  terminal NUMBER: /[0-9]+(\.[0-9]+)?/;
  terminal ID: /[_a-zA-Z][\w_-]*/;                                                                                                                                                                                                
  hidden terminal WS: /\s+/;  

hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//;
hidden terminal SL_COMMENT: /\/\/[^\n\r]*/;

@msujew
Copy link
Copy Markdown
Member Author

msujew commented Apr 30, 2026

@cdietrich I've added your test, and probably found a good compromise. I had to add an incomplete flag to the lookahead to make this work - but I believe it does now work as expected. See #2147.

@cdietrich
Copy link
Copy Markdown
Contributor

@msujew my first testcase still does not work
need to double check i did not screw stuff up in building it
can we still produce alphas?

@msujew
Copy link
Copy Markdown
Member Author

msujew commented Apr 30, 2026

my first testcase still does not work

I've reverted all changes related to the parsing phase - the only difference should now be in the completion phase.

can we still produce alphas?

I have pushed a next release for you, see 4.2.2-next.d9c47299.

@cdietrich
Copy link
Copy Markdown
Contributor

ok the 2nd test as a escape problem in the ts backtick string literal
i am still evaluating the results in the completion tests

@cdietrich
Copy link
Copy Markdown
Contributor

update: they look promising

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.

Content assist does not work for common prefix rules

2 participants