vscode-tcl icon indicating copy to clipboard operation
vscode-tcl copied to clipboard

Formatter over indents when slash (new line continuation) is nested

Open maciejmatczak opened this issue 4 years ago • 2 comments

Hi there! The auto save format that just appeared in my .tcl files is like an additional gift from last Christmas ;). Thanks!

To the issue:

proc myProc {a b} {
    ns::setSomething \
        [differentNs::verLongCommandHenceMultilined \
            "very long input argument"]
}

For me this is a well formatted TCL code, not sure if I introduce some not needed characters. I am dealing with long named, nested invocation and sometimes try to rescue readability with new line continuation.

Formatter is not able to understand it and it results as:

proc myProc {a b} {
    ns::setSomething \
        [differentNs::verLongCommandHenceMultilined \
            "very long input argument"]
    }

Last bracket over indented. Seems related to nested square brackets eval and line continuation also there, as this:

proc myProc {a b} {
    ns::setSomething \
        [differentNs::verLongCommandHenceMultilined "very long input argument"]
}

... works fine. If you could initially guide me, do you have some tests coverage for formatting? I should be able to work on some PR if something would be already existing. Other than that, I have 0 experience in creating VSCode plugins.

maciejmatczak avatar Jan 18 '21 16:01 maciejmatczak

https://github.com/bitwisecook/vscode-tcl/blob/5148b946adc5b3a4e1b63978735f9060b13c462e/src/formatProvider.ts#L46 is a boolean. So we do not support any nesting there, right?

For that we would need to have continuation to have levels like indentation, am I right?

maciejmatczak avatar Jan 19 '21 06:01 maciejmatczak

@maciejmatczak yes, I'd be happy to receive pull requests for this

bitwisecook avatar Nov 13 '22 12:11 bitwisecook