Skip to content

PowerShell: Remove backtick escape in single-quoted strings#92

Closed
xv wants to merge 2 commits intoScintillaOrg:masterfrom
xv:p92
Closed

PowerShell: Remove backtick escape in single-quoted strings#92
xv wants to merge 2 commits intoScintillaOrg:masterfrom
xv:p92

Conversation

@xv
Copy link
Copy Markdown

@xv xv commented Jun 17, 2022

Came across this issue of my syntax highlighting getting messed up and found the culprit to be the backtick character escaping in single-quoted strings, which is incorrect behavior.

From MSDN:

Because the contents of single-quoted strings are interpreted literally, the backtick character is treated as a literal character and displayed in the output.
Source

Current incorrect behaviour:

incorrect

Corrected behaviour in PR:

correct

@nyamatongwe nyamatongwe added the powershell Caused by the PowerShell lexer label Jun 18, 2022
@nyamatongwe
Copy link
Copy Markdown
Member

This bug has also been reported as Scintilla#2209

This behaviour stems from fixing bug #1929 with commit 6734b0 which added backtick quotes for both string types.

@xv
Copy link
Copy Markdown
Author

xv commented Jun 18, 2022

I have reviewed and tested commit 6734b0. Escapes in double-quoted strings are correctly implemented; however, escapes in single-quoted strings definitely shouldn't happen.

Also tested on PowerShell ISE:

ise

And VSCode:
vscode

@nyamatongwe
Copy link
Copy Markdown
Member

Pushed 7758276 which includes the code change and updates the test case a little.

The comments in the test case were converted to block comments <# ... #> because the lexer styles the \r and \n differently after line comments. This is a common problem in lexers and upsets the test runner - it is also a great source of bugs. The test case was also named after this issue Pull92.ps1 as is convention for files that are illustrating a particular issue. Turned on folding in properties as its likely to be relevant in future issues.

@nyamatongwe nyamatongwe added the committed Issue fixed in repository but not in release label Jun 18, 2022
@xv
Copy link
Copy Markdown
Author

xv commented Jun 18, 2022

Looks great -- thank you for your time :)

@nyamatongwe nyamatongwe closed this Jul 9, 2022
@xv xv deleted the p92 branch July 9, 2022 21:03
@nyamatongwe nyamatongwe removed the committed Issue fixed in repository but not in release label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

powershell Caused by the PowerShell lexer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants