Compare commits

...
3 Commits
Author SHA1 Message Date
Christoph Brandau 579847b56d fix formatter
/ build_and_publish (release) Successful in 33s
2025-08-12 11:35:54 +02:00
Christoph Brandau 618d6b478b fix: formatter when \ was deleting 2025-08-12 11:28:10 +02:00
Christoph cf62044d3e Update version to 2025.8.201 2025-08-11 19:37:32 +00:00
3 changed files with 34 additions and 2 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "nx-post-support", "name": "nx-post-support",
"displayName": "NX Postprocessor Support", "displayName": "NX Postprocessor Support",
"description": "", "description": "",
"version": "2025.9.0", "version": "2025.8.201",
"publisher": "Christoph", "publisher": "Christoph",
"icon": "images/nx-1.png", "icon": "images/nx-1.png",
"serverInfo": { "serverInfo": {
+2 -1
View File
@@ -4,7 +4,8 @@ from typing import List, Optional, Tuple
import lsprotocol.types as lsp import lsprotocol.types as lsp
from pygls.workspace.text_document import TextDocument from pygls.workspace.text_document import TextDocument
from tclint.lexer import TclSyntaxError from tclint.lexer import TclSyntaxError
from tclint.format import Formatter, FormatterOpts from tclint.format import FormatterOpts
from tools.formatter import NxFormatter as Formatter
from tclint.violations import Violation from tclint.violations import Violation
from plugins.poco_plugin import commands from plugins.poco_plugin import commands
from tools import checks, parser from tools import checks, parser
+31
View File
@@ -0,0 +1,31 @@
from tclint.format import Formatter as BaseFormatter
from typing import List
class NxFormatter(BaseFormatter):
"""
Custom formatter that inherits from tclint's Formatter but preserves explicit
line continuations (\\) inside braced expressions when they span multiple lines.
This avoids generating syntax errors in environments that require a trailing
backslash for multi-line expressions (e.g., certain NX Post interpreters),
while leaving all other formatting behavior unchanged.
"""
def format_braced_expression(self, expr) -> List[str]: # type: ignore[override]
# This method mirrors BaseFormatter.format_braced_expression but inserts
# a line continuation (" \") between continuation lines similar to
# BaseFormatter.format_expression.
formatted = [""]
for child in expr.children:
lines = self.format(child)
formatted[-1] += lines[0]
for line in lines[1:]:
# add continuation on the previous line; keep next line at the same level
formatted[-1] += " \\" # keep explicit continuation
formatted += [line]
if expr.pos[0] == expr.end_pos[0]:
return self._brace(formatted)
return ["{"] + self._indent(formatted, self.opts.indent) + ["}"]