Keep leading comments in proc bodies unindented #66
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!66
Loading…
Reference in a new issue
No description provided.
Delete branch "58-nocomplain-is-missing"
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 adjusts the formatter to preserve leading header comments inside procedure bodies at the procedure's own indentation level, and fixes the Tcl completion metadata for the
unsetoption to include its leading-.What changed
Formatter behavior
self._proc_bodies) when formatting commands and, when formatting a script that is a proc body, leaves comment lines that appear before the first real command unindented. Everything from the first real command onward (including subsequent comments) is indented normally.NxFormatter.__init__initializes_proc_bodies;format_commandrecords the proc bodyid(...)for procs;format_scriptpost-processes the script lines to remove the extra indentation from leading comment lines.Tcl completion metadata
OPTIONS_BY_PATHentry for("unset",)now lists the option as"-nocomplain"(with the leading dash) rather than"nocomplain", so completion will suggest the hyphen-prefixed flag.tcl_command_completion.pyto compress multi-line comprehensions into single-line forms; these are formatting-only and do not change behavior.Tests
server/tests/python_tests/test_formatter.pywas updated: an existing test's expected output includes aset y 2line and a new testtest_leading_proc_comments_are_not_indentedwas added to assert the new indentation semantics for proc header comments.Why this matters (evidence-based)
proc { ... }body. The diff shows code that records proc bodies and then strips one level of indent from leading comment lines in those bodies; the new test exercises that exact case.OPTIONS_BY_PATHmapping forunsetso the completion system will include the correct literal-nocomplainflag.Tests
No test execution results were provided.
Recommended checks for reviewers:
python -m pytest server/tests/python_tests/test_formatter.py::test_leading_proc_comments_are_not_indentedpython -m pytest server/tests/python_tests/test_formatter.pyCompatibility / reviewer notes
unsetby including the leading-. If any consumer relied on the previous no-dash entry inOPTIONS_BY_PATH, update accordingly.id(...)) to correlate a recorded proc body with the subsequentformat_scriptcall; this is consistent with the existing formatter call pattern in the diff but is worth noting if the formatter call ordering or object reuse changes in future.No other migration or configuration changes are required.
Closes #58
Adjust test expectation to match completion item labels that include the leading hyphen for the unset option. Previously the test asserted {"nocomplain"}; it now asserts {"-nocomplain"} so the test reflects the actual completion output. Also tidy up import ordering in the test file for clarity. Fixes #58Pull request closed