FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix unnecessary trimming of line resulting in incorrect indexi… by SteveL-MSFT · Pull Request #11670 · PowerShell/PowerShell · GitHub

Fix unnecessary trimming of line resulting in incorrect indexi… - #11670

Merged
Travis Plunk (TravisEz13) merged 4 commits into
PowerShell:masterfrom
SteveL-MSFT:error-indent
Jan 30, 2020
Merged

Fix unnecessary trimming of line resulting in incorrect indexi…#11670
Travis Plunk (TravisEz13) merged 4 commits into
PowerShell:masterfrom
SteveL-MSFT:error-indent

Conversation

Steve Lee (SteveL-MSFT) commented Jan 24, 2020
edited
Loading

Copy link
Copy Markdown
Member

PR Summary

After the switch to use InvocationInfo.PositionMessage instead of crafting equivalent, the use of Trim() caused a mismatch between the line of script with the error and the underlining line so the line of code to insert VT100 color can be out of bounds. The whitespace at the beginning of the line causes this issue because Trim() makes the highlight line too short (previously the script line would also be trimmed).

Also fixed an issue where it was splitting PositionMessage by + to get the individual parts, but the message itself can contain a + so using newline instead. This with the trim is what caused the index to be out of bounds as the line is now too short to insert the VT100 code to reset the color back.

In addition, switched all use of `n to [Environment]::Newline.

Finally, removed an extra newline in the rendering.

PR Context

Fix #11669

PR Checklist

replace `n with [environment]::newline
remove extra newline
Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jan 24, 2020

Copy link
Copy Markdown
Collaborator

We have many issues with these helper functions. Maybe put them in a temp module? This can simplify debugging and fixing.

Copy link
Copy Markdown
Member Author

Ilya (@iSazonov) which helpers are you referring to? The tests don't really have any helpers?

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT) I mean the formatting functions like Show-Error and Get-ConciseViewPositionMessage.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

All this code seems pretty fragile and relies on the format of the error message which could change at any time. There's not much we can do about other that to rethink the whole error presentation which is probably not something we should entertain at the moment.

Copy link
Copy Markdown
Member Author

Ilya (@iSazonov) In 7.1, we'll have appropriate APIs for coloring/VT100, we can consider some refactoring then vs making a big change now

Travis Plunk (TravisEz13) changed the title fix unncessary trimming of line resulting in incorrect indexing fix unnecessary trimming of line resulting in incorrect indexing in errors Jan 30, 2020
Travis Plunk (TravisEz13) changed the title fix unnecessary trimming of line resulting in incorrect indexing in errors Fix unnecessary trimming of line resulting in incorrect indexi… Jan 30, 2020
Travis Plunk (TravisEz13) merged commit 66912b7 into PowerShell:master Jan 30, 2020
Steve Lee (SteveL-MSFT) deleted the error-indent branch January 30, 2020 21:12

Copy link
Copy Markdown

🎉v7.0.0-rc.3 has been released which incorporates this pull request.:tada:

Handy links:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Still some bugs in error formatting, indent somehow involved

7 participants


Back | FazBrowse Home | New Git URL