TaoK / PoorMansTSqlFormatter

A small free .Net and JS library (with demo UI, command-line bulk formatter, SSMS/VS add-in, notepad++ plugin, winmerge plugin, and demo webpage) for reformatting and coloring T-SQL code to the user's preferences.
http://www.architectshack.com/PoorMansTSqlFormatter.ashx
GNU Affero General Public License v3.0
947 stars 266 forks source link

[noformat][/noformat] block adds a linefeed before [/noformat] everytime the document is formatted #292

Open mc-Jeeves opened 1 month ago

mc-Jeeves commented 1 month ago

When formatting a dockument in SSMS a new line and spacing is inserted before the [/noformat] tag. This is done every time the document is formatted resulting in more and more empty lines above the [/noformat] tag: Original query:

IF @Ref IS NULL
BEGIN
    IF @DebugMsg = 'x1'
    BEGIN
        --[noformat]
        PRINT 'Some debug info'
        --[/noformat]
    END
    --[noformat]
    SELECT something from table
    --[/noformat]
END;

Formatted once:

IF @Ref IS NULL
BEGIN
    IF @DebugMsg = 'x1'
    BEGIN
        --[noformat]
        PRINT 'Some debug info'

            --[/noformat]
    END

    --[noformat]
    SELECT something from table

        --[/noformat]
END;

Formatted twice:

IF @Ref IS NULL
BEGIN
    IF @DebugMsg = 'x1'
    BEGIN
        --[noformat]
        PRINT 'Some debug info'

            --[/noformat]
    END

    --[noformat]
    SELECT something from table

        --[/noformat]
END;