Skip to content

Commit 40a0285

Browse files
theaquamarinedaxian-dbw
authored andcommitted
Allow SmartInsertQuote to surround a keyword or variable (#1289)
1 parent 57e9e11 commit 40a0285

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

PSReadLine/SamplePSReadLineProfile.ps1

+3-2
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,14 @@ Set-PSReadLineKeyHandler -Key '"',"'" `
202202
}
203203

204204
if ($token.Extent.StartOffset -eq $cursor) {
205-
if ($token.Kind -eq [TokenKind]::Generic -or $token.Kind -eq [TokenKind]::Identifier) {
205+
if ($token.Kind -eq [TokenKind]::Generic -or $token.Kind -eq [TokenKind]::Identifier -or
206+
$token.Kind -eq [TokenKind]::Variable -or $token.TokenFlags.hasFlag([TokenFlags]::Keyword)) {
206207
$end = $token.Extent.EndOffset
207208
$len = $end - $cursor
208209
[Microsoft.PowerShell.PSConsoleReadLine]::Replace($cursor, $len, $quote + $line.SubString($cursor, $len) + $quote)
209210
[Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($end + 2)
211+
return
210212
}
211-
return
212213
}
213214

214215
# We failed to be smart, so just insert a single quote

0 commit comments

Comments
 (0)