Skip to content

Commit de70d47

Browse files
committed
1 parent 0a33122 commit de70d47

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandSimplifier.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export class CommandSimplifier {
8484
private async _rewriteUnsupportedPwshChainOperators(commandLine: string, os: OperatingSystem, shell: string) {
8585
// TODO: This should just be Windows PowerShell in the future when the powershell grammar
8686
// supports chain operators https://github.com/airbus-cert/tree-sitter-powershell/issues/27
87-
if (isPowerShell(shell, os)) {
87+
const disablePowerShellRewrites = true; // see https://github.com/microsoft/vscode/issues/273177
88+
if (!disablePowerShellRewrites && isPowerShell(shell, os)) {
8889
const doubleAmpersandCaptures = await this._treeSitterCommandParser.queryTree(TreeSitterCommandParserLanguage.PowerShell, commandLine, [
8990
'(',
9091
' (command',

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,32 @@ export class TreeSitterCommandParser {
2424
}
2525

2626
async extractSubCommands(languageId: TreeSitterCommandParserLanguage, commandLine: string): Promise<string[]> {
27-
const parser = await this._parser;
28-
const language = await waitForState(derived(reader => {
29-
return this._treeSitterLibraryService.getLanguage(languageId, true, reader);
30-
}));
31-
parser.setLanguage(language);
27+
const disableSubCommandExtraction = true; // see https://github.com/microsoft/vscode/issues/273177
3228

33-
const tree = parser.parse(commandLine);
34-
if (!tree) {
35-
throw new BugIndicatingError('Failed to parse tree');
36-
}
29+
if (disableSubCommandExtraction) {
30+
throw new Error('not supported');
31+
} else {
32+
const parser = await this._parser;
33+
const language = await waitForState(derived(reader => {
34+
return this._treeSitterLibraryService.getLanguage(languageId, true, reader);
35+
}));
36+
parser.setLanguage(language);
3737

38-
const query = await this._getQuery(language);
39-
if (!query) {
40-
throw new BugIndicatingError('Failed to create tree sitter query');
41-
}
38+
const tree = parser.parse(commandLine);
39+
if (!tree) {
40+
throw new BugIndicatingError('Failed to parse tree');
41+
}
4242

43-
const captures = query.captures(tree.rootNode);
44-
const subCommands = captures.map(e => e.node.text);
43+
const query = await this._getQuery(language);
44+
if (!query) {
45+
throw new BugIndicatingError('Failed to create tree sitter query');
46+
}
47+
48+
const captures = query.captures(tree.rootNode);
49+
const subCommands = captures.map(e => e.node.text);
4550

46-
return subCommands;
51+
return subCommands;
52+
}
4753
}
4854

4955
async queryTree(languageId: TreeSitterCommandParserLanguage, commandLine: string, querySource: string): Promise<QueryCapture[]> {

0 commit comments

Comments
 (0)