Avoid continuations for script lines in braced expressions #75
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
state: Done
state: New
type: Bug
type: Feature
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Christoph/nx_post_support!75
Loading…
Reference in a new issue
No description provided.
Delete branch "72-indent-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change prevents the formatter from inserting line-continuation backslashes between lines that come from script bodies (for example, a
catchbody) when those scripts appear inside a braced expression. It also standardizes the LSP server's indentation to always use 4 spaces.Summary of behavior changes
Formatter: introduces a hidden marker (
_SCRIPT_LINE) and an expression-depth counter (_expr_depth) to detect lines produced inside a command substitution while formatting a braced expression. Lines marked as script lines are not given a trailing\continuation when the braced expression formatter would otherwise add one. The marker is removed from the final output and empty-looking lines are preserved as empty strings.NxFormatter.format_command_subnow tags subsequent lines with the marker when formatting command substitutions while inside an expression.NxFormatter.format_braced_expressionincrements/decrements_expr_deptharound its work, skips inserting continuation backslashes for marked script lines, and strips the marker afterward.LSP server indentation:
TclLanguageServernow sets the formatterindentto four spaces unconditionally (indent = " " * 4) instead of deriving indentation fromoptions.insert_spacesandoptions.tab_size.Why this change matters
\between continuation lines. When a command substitution produced lines that were actually a script body (multiple separate commands), adding\could unintentionally join separate commands into a single continued command.Files changed (high level)
server/src/tools/formatter.py: add_SCRIPT_LINEmarker, track expression depth, tag command-substitution lines, and avoid adding\for script lines in braced expressions.server/src/lsp_tclserver.py: force 4-space indentation in the formatter options.server/tests/python_tests/test_formatter.py: addtest_catch_body_in_braced_expression_gets_no_continuationto assert the intended formatting for acatchbody inside a braced expression.Testing
No test execution results were provided.
Recommended checks for reviewers
pytest server/tests/python_tests/test_formatter.py(or the project's test suite) and inspect the new testtest_catch_body_in_braced_expression_gets_no_continuation.catch { ... }) and confirm no\continuations are inserted inside that script body.insertSpaces/tabSizesettings; verify this is intended for your environment.Compatibility / reviewer notes
_SCRIPT_LINEmarker is an internal implementation detail; the code strips it before producing final output, so no marker should appear in formatted files.If you want, I can run through a few representative examples of input/output formatting to demonstrate the change further.
Closes #72