Open RaghavendraDasara opened 5 years ago
Hi, it's a little difficult to follow what you're saying here, partially because of formatting confusion I suspect.
I think you're saying that your comments "--
The reason these comments are being deleted (I assume - it's hard to follow your example) is because you are using the "minify" instruction to the formatter. "minify" means "make it as small as possible, removing as much whitespace as possible and removing all comments".
The "noformat" and the "minify" instructions are separate and intended to achieve different things. "noformat" means "please leave it as it is, I like it like that", and "minify" means "please make it as compact as possible".
Please let me know if this addresses your concern, or if I've misunderstood your intent.
Please go through below code.If you have any concerns, kindly let me know.
Example Code: INSERT INTO @test ( ID, Name --Commented Line 1 --Commented Line 12 )
SELECT 1, 'Test poor man'
After Applying "Format T-SQL Code" in SSMS Commented lines moving out from insert into parenthesis. You can see below example: INSERT INTO @test ( ID, Name ) --Commented Line 1 --Commented Line 2 SELECT 1, 'Test poor man'
Expected Result : Code should be formatted and comment lines should be within insert statement parenthesis : INSERT INTO @test ( ID, Name --Commented Line 1 --Commented Line 2 )
SELECT 1, 'Test poor man'
Code before formatting : INSERT INTO @test ( ID, -- Comment before last column Name -- Comment after last column and before closing parenthesis ) -- Comment after closing parenthesis SELECT 1, 'Test poor man'
After Applying "Format T-SQL Code" in SSMS INSERT INTO @test ( ID, -- Comment before last column Name ) -- Comment after last column and before closing parenthesis -- Comment after closing parenthesis SELECT 1, 'Test poor man'
Expected : INSERT INTO @test ( ID, -- Comment before last column Name -- Comment after last column and before closing parenthesis ) -- Comment after closing parenthesis SELECT 1, 'Test poor man'
Hi @TaoK , I will try to bring some light to this issue to see if you could assists with a solution. Refering to the example above. The problem is that the complete line with the comment is moved to another place in the code.
Having a look at the example below:
INSERT INTO @test ( ID, -- Comment before last column Name -- Comment after last column and before closing parenthesis ) -- Comment after closing parenthesis SELECT 1, 'Test poor man'
The line:
-- Comment after last column and before closing parenthesis
is moved to after the line after the closing parentheses.
Using [noformat]-tag the formatting of the code is still performed so the commented line is moved to after closing parantheses line. Using [noformat] is not an option to solve this issue as it is right now. The "noformat" (please leave it as it is) does not work for my example.
Example : Code before formatting INSERT INTO @test ( ID, Name
---- /[minify]/ /[noformat]/ -- [minify]
-- -- [/minify] -- [/noformat] /[/noformat]/ ---- /[/minify]/
)
Example : Code after formatting
INSERT INTO @test ( ID, Name ) ---- /[minify]/
-- [/minify]
-- [/noformat] /[/noformat]/ ---- /[/minify]/ SELECT 1, 'Test poor man'
--
i used minify and noformat option to avoid formatting for within that block still it is formatting.i don't want to format some of the lines.Please resolve the issue as early as possible. Expected result : INSERT INTO @test ( ID, Name
---- /[minify]/
-- [/minify]
-- [/noformat] /[/noformat]/ ---- /[/minify]/
SELECT 1, 'Test poor man'
--