We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
When the formatter prepend/append oneSpace or noSpace on a token, it break the document if a single line is between the 2 tokens
Langium version: 3.1.0 Package name: langium-lsp
grammar HelloWorld entry Model: (persons+=Person | greetings+=Greeting)*; Person: 'person' name=ID; Greeting: 'Hello' person=[Person:ID] '!'; hidden terminal WS: /\s+/; terminal ID: /[_a-zA-Z][\w_]*/; hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//; hidden terminal SL_COMMENT: /\/\/[^\n\r]*/;
export class HelloFormatter extends AbstractFormatter { protected format(node: AstNode): void { if (ast.isPerson(node)) { const formatter = this.getNodeFormatter(node); formatter.property('name').prepend(Formatting.oneSpace()) } } }
person //comment John
After the formatting the name is moved at the end of the single line comment
person //commentJohn
The text was updated successfully, but these errors were encountered:
Here is a temporary workaround that works only if rule name is SL_COMMENT:
langium/packages/langium/src/lsp/formatter.ts
Line 230 in b2c40e3
Skip the prepend formatting if the lastNode rule is SL_COMMENT
if (!lastNode?.hidden || isLeafCstNode(lastNode) && lastNode.tokenType.name !== 'SL_COMMENT') { const nodeEdits = this.createTextEdit(lastNode, node, prependFormatting, context); for (const edit of nodeEdits) { if (edit && this.insideRange(edit.range, range)) { edits.push(edit); } } }
Sorry, something went wrong.
fixed by #1628
No branches or pull requests
Hello,
When the formatter prepend/append oneSpace or noSpace on a token, it break the document if a single line is between the 2 tokens
Langium version: 3.1.0
Package name: langium-lsp
Steps To Reproduce
The current behavior
After the formatting the name is moved at the end of the single line comment
The expected behavior
The text was updated successfully, but these errors were encountered: