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

Comment-Based Help after function name indents improperly on "Format Document"

Open JustinGrote opened this issue 3 years ago • 7 comments

Prerequisites

  • [X] I have written a descriptive issue title.
  • [X] I have searched all issues to ensure it has not already been reported.
  • [X] I have read the troubleshooting guide.
  • [X] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • [X] If this is a security issue, I have read the security issue reporting guidance.

Summary

Comment block indents during formatting when it shouldn't. Doesn't occur if block is above the function or if the whole block is already indented.

PowerShell Version

Latest

Visual Studio Code Version

1.67.0-insider
e6d98a13fcd3bf928d0e755eaae873ac200a98bd
x64

Extension Version

[email protected]

Steps to Reproduce

  1. Create Function
  2. Comment based help on same line as function
  3. Format document or format-on-save

Visuals

https://user-images.githubusercontent.com/15258962/163913559-fd6f3949-1f40-433f-820b-6e81e995711c.mp4

Logs

No response

JustinGrote avatar Apr 19 '22 03:04 JustinGrote

Isn't comment-based help supposed to go above the function, not in the function definition? Anyway, this looks like a PSSA issue, can you repro it using PSSA directly to format?

andyleejordan avatar Apr 19 '22 16:04 andyleejordan

Hopefully fixed now.

andyleejordan avatar Apr 20 '22 00:04 andyleejordan

Isn't comment-based help supposed to go above the function, not in the function definition? Anyway, this looks like a PSSA issue, can you repro it using PSSA directly to format?

3 locations are supported, with "below the function keyword" being the conventional default (this differs from the C#/Typescript XMLDoc/JSDoc norm of above the function declaration)

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help?view=powershell-7.2#syntax-for-comment-based-help-in-functions

JustinGrote avatar Apr 20 '22 02:04 JustinGrote

Ah, good to know! I'm not sure why this would be fixed by the last PR, just that it seemed so during a triage meeting. I'll try to repro and test.

andyleejordan avatar Apr 20 '22 15:04 andyleejordan

@andschwa FYI still happening in v2022.4.2

JustinGrote avatar Apr 21 '22 15:04 JustinGrote

Thought it would, sorry! Huge blocker?

andyleejordan avatar Apr 21 '22 16:04 andyleejordan

Thought it would, sorry! Huge blocker?

Not for stable RC, minor annoyance at best, you can always "save without formatting" or just move it above.

JustinGrote avatar Apr 22 '22 14:04 JustinGrote