diff --git a/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/rubyCommandLinePresenter.ts b/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/rubyCommandLinePresenter.ts index 14f087f85eb0..7f6f078d0705 100644 --- a/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/rubyCommandLinePresenter.ts +++ b/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/rubyCommandLinePresenter.ts @@ -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+'(?.+)'$/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;