mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-27 19:08:21 +01:00
Add explicit empty code checks in Ruby presenter
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
This commit is contained in:
co-authored by
Tyriar
parent
a0278fa841
commit
64baba2b0e
+8
-1
@@ -40,6 +40,11 @@ export function extractRubyCommand(commandLine: string, shell: string, os: Opera
|
||||
if (doubleQuoteMatch?.groups?.code) {
|
||||
let rubyCode = doubleQuoteMatch.groups.code.trim();
|
||||
|
||||
// Return undefined if the trimmed code is empty
|
||||
if (!rubyCode) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Unescape quotes based on shell type
|
||||
if (isPowerShell(shell, os)) {
|
||||
// PowerShell uses backtick-quote (`") to escape quotes inside double-quoted strings
|
||||
@@ -57,7 +62,9 @@ export function extractRubyCommand(commandLine: string, shell: string, os: Opera
|
||||
// Single quotes in PowerShell are also literal
|
||||
const singleQuoteMatch = commandLine.match(/^ruby\s+-e\s+'(?<code>.+)'$/s);
|
||||
if (singleQuoteMatch?.groups?.code) {
|
||||
return singleQuoteMatch.groups.code.trim();
|
||||
const rubyCode = singleQuoteMatch.groups.code.trim();
|
||||
// Return undefined if the trimmed code is empty
|
||||
return rubyCode || undefined;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user