Skip to content

Commit fbf71d8

Browse files
committed
revert alias changes and move terminalContributions back
1 parent d86e54c commit fbf71d8

File tree

12 files changed

+15
-99
lines changed

12 files changed

+15
-99
lines changed

src/vs/platform/terminal/common/capabilities/capabilities.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ export interface ICommandDetectionCapability {
159159
readonly onCurrentCommandInvalidated: Event<ICommandInvalidationRequest>;
160160
setCwd(value: string): void;
161161
setIsWindowsPty(value: boolean): void;
162-
setAliases(value: string): void;
163162
setIsCommandStorageDisabled(): void;
164163
/**
165164
* Gets the working directory for a line, this will return undefined if it's unknown in which
@@ -252,7 +251,6 @@ export interface ISerializedCommand {
252251
commandStartLineContent: string | undefined;
253252
timestamp: number;
254253
markProperties: IMarkProperties | undefined;
255-
aliases: string[][] | undefined;
256254
}
257255
export interface IMarkProperties {
258256
hoverMessage?: string;

src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export class CommandDetectionCapability implements ICommandDetectionCapability {
5858
private _cwd: string | undefined;
5959
private _currentCommand: ICurrentPartialCommand = {};
6060
private _isWindowsPty: boolean = false;
61-
private _aliases: string[][] = [];
6261
private _onCursorMoveListener?: IDisposable;
6362
private _commandMarkers: IMarker[] = [];
6463
private _dimensions: ITerminalDimensions;
@@ -271,10 +270,6 @@ export class CommandDetectionCapability implements ICommandDetectionCapability {
271270
this._isWindowsPty = value;
272271
}
273272

274-
setAliases(value: string): void {
275-
this._aliases = parseAliases(value, this._isWindowsPty);
276-
}
277-
278273
setIsCommandStorageDisabled(): void {
279274
this.__isCommandStorageDisabled = true;
280275
}
@@ -580,8 +575,7 @@ export class CommandDetectionCapability implements ICommandDetectionCapability {
580575
exitCode: undefined,
581576
commandStartLineContent: undefined,
582577
timestamp: 0,
583-
markProperties: undefined,
584-
aliases: this._aliases
578+
markProperties: undefined
585579
});
586580
}
587581
return {
@@ -783,33 +777,3 @@ function countNewLines(regex: RegExp): number {
783777
}
784778
return count;
785779
}
786-
787-
function parseAliases(aliasString: string, isWindows?: boolean): string[][] {
788-
const aliases: string[][] = [];
789-
let shellType;
790-
const rows = aliasString.split('\n');
791-
if (isWindows || aliasString.includes('Definition')) {
792-
shellType = 'pwsh';
793-
// Remove the column headers
794-
rows.shift();
795-
rows.shift();
796-
rows.shift();
797-
} else if (rows.length > 1 && rows[1].startsWith('alias')) {
798-
shellType = 'bash';
799-
} else {
800-
shellType = 'zsh';
801-
}
802-
803-
for (const row of rows) {
804-
if (shellType === 'zsh') {
805-
aliases.push(row.split('='));
806-
} else if (shellType === 'bash') {
807-
aliases.push(row.substring(6).split('='));
808-
} else {
809-
// to do - way to avoid this filtering?
810-
aliases.push(row.split(' ').filter(s => !!s.trim()));
811-
}
812-
}
813-
console.log(aliases);
814-
return aliases;
815-
}

src/vs/platform/terminal/common/terminal.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { IPtyHostProcessReplayEvent, ISerializedCommandDetectionCapability, ITer
1111
import { IGetTerminalLayoutInfoArgs, IProcessDetails, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
1212
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
1313
import { ISerializableEnvironmentVariableCollections } from 'vs/platform/terminal/common/environmentVariable';
14+
import { ITerminalCommandSelector } from 'vs/platform/terminal/common/xterm/terminalQuickFix';
1415

1516

1617
export const enum TerminalSettingPrefix {
@@ -817,6 +818,11 @@ export interface IShellIntegration {
817818
deserialize(serialized: ISerializedCommandDetectionCapability): void;
818819
}
819820

821+
export interface ITerminalContributions {
822+
profiles?: ITerminalProfileContribution[];
823+
quickFixes?: ITerminalCommandSelector[];
824+
}
825+
820826
export const enum ShellIntegrationStatus {
821827
/** No shell integration sequences have been encountered. */
822828
Off,

src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,6 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
371371
this.capabilities.get(TerminalCapability.CommandDetection)?.setIsCommandStorageDisabled();
372372
return true;
373373
}
374-
case 'UserAliases': {
375-
this._createOrGetCommandDetection(this._terminal).setAliases(value);
376-
return true;
377-
}
378374
}
379375
}
380376
case VSCodeOscPt.SetMark: {

src/vs/platform/terminal/common/xterm/terminalQuickFix.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { IAction } from 'vs/base/common/actions';
88
import { CancellationToken } from 'vs/base/common/cancellation';
99
import { UriComponents } from 'vs/base/common/uri';
1010
import { ITerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities';
11-
import { ITerminalProfileContribution } from 'vs/platform/terminal/common/terminal';
1211

1312
export interface ITerminalCommandSelector {
1413
id: string;
@@ -87,11 +86,6 @@ export interface IUnresolvedExtensionOptions extends ITerminalQuickFixOptions {
8786
type: 'unresolved';
8887
}
8988

90-
export interface ITerminalContributions {
91-
profiles?: ITerminalProfileContribution[];
92-
quickFixes?: ITerminalCommandSelector[];
93-
}
94-
9589

9690
/**
9791
* A matcher that runs on a sub-section of a terminal command's output

src/vs/workbench/api/browser/mainThreadTerminalService.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { Promises } from 'vs/base/common/async';
2525
import { CancellationToken } from 'vs/base/common/cancellation';
2626
import { ITerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities';
2727
import { ITerminalOutputMatch, ITerminalOutputMatcher, ITerminalQuickFixOptions } from 'vs/platform/terminal/common/xterm/terminalQuickFix';
28-
import { resolveAliases } from 'vs/workbench/contrib/terminal/browser/xterm/quickFixAddon';
2928

3029
@extHostNamedCustomer(MainContext.MainThreadTerminalService)
3130
export class MainThreadTerminalService implements MainThreadTerminalServiceShape {
@@ -260,15 +259,8 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
260259
option.outputMatcher.length = 40;
261260
this._logService.warn('Cannot exceed output matcher length of 40');
262261
}
263-
let commandLineMatch = terminalCommand.command.match(option.commandLineMatcher);
262+
const commandLineMatch = terminalCommand.command.match(option.commandLineMatcher);
264263
if (!commandLineMatch) {
265-
if (terminalCommand.aliases) {
266-
const resolvedCommand = resolveAliases(terminalCommand.command, terminalCommand.aliases);
267-
commandLineMatch = resolvedCommand.match(option.commandLineMatcher);
268-
if (!commandLineMatch) {
269-
return;
270-
}
271-
}
272264
return;
273265
}
274266
const outputMatcher = option.outputMatcher;

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,3 @@ if [[ -z "${bash_preexec_imported:-}" ]]; then
206206
PROMPT_COMMAND=__vsc_prompt_cmd
207207
fi
208208
fi
209-
result=$(alias)
210-
result=$(echo $result | sed 's/\"/\\/g')
211-
result=$(echo $result | sed 's/`n/\x0a/g')
212-
result=$(echo $result | sed 's/;/\x3b/g')
213-
echo -ne "\x1b]633;P;UserAliases=$result"

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-rc.zsh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,3 @@ add-zsh-hook preexec __vsc_preexec
130130
if [[ $options[login] = off && $USER_ZDOTDIR != $VSCODE_ZDOTDIR ]]; then
131131
ZDOTDIR=$USER_ZDOTDIR
132132
fi
133-
result=$(alias)
134-
result=$(echo $result | sed 's/\"/\\/g')
135-
result=$(echo $result | sed 's/`n/\x0a/g')
136-
result=$(echo $result | sed 's/;/\x3b/g')
137-
echo -ne "\x1b]633;P;UserAliases=$result"

src/vs/workbench/contrib/terminal/browser/xterm/quickFixAddon.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export async function getQuickFixesForCommand(
311311
const onDidRunQuickFixEmitter = new Emitter<string>();
312312
const onDidRunQuickFix = onDidRunQuickFixEmitter.event;
313313
const fixes: ITerminalAction[] = [];
314-
const newCommand = resolveAliases(terminalCommand.command, aliases);
314+
const newCommand = terminalCommand.command;
315315
const expectedCommands = [];
316316
for (const options of quickFixOptions.values()) {
317317
for (const option of options) {
@@ -328,13 +328,9 @@ export async function getQuickFixesForCommand(
328328
}
329329
quickFixes = await getResolvedFixes(option, option.outputMatcher ? getLinesForCommand(terminal.buffer.active, terminalCommand, terminal.cols, option.outputMatcher) : undefined);
330330
} else if (option.type === 'internal') {
331-
let commandLineMatch = newCommand.match(option.commandLineMatcher);
331+
const commandLineMatch = newCommand.match(option.commandLineMatcher);
332332
if (!commandLineMatch) {
333-
const resolvedAliasesCommand = resolveAliases(newCommand, terminalCommand.aliases);
334-
commandLineMatch = resolvedAliasesCommand.match(option.commandLineMatcher);
335-
if (!commandLineMatch) {
336-
continue;
337-
}
333+
continue;
338334
}
339335
const outputMatcher = option.outputMatcher;
340336
let outputMatch;
@@ -430,16 +426,3 @@ function convertToQuickFixOptions(selectorProvider: ITerminalQuickFixProviderSel
430426
getQuickFixes: selectorProvider.provider.provideTerminalQuickFixes
431427
};
432428
}
433-
434-
export function resolveAliases(commandLine: string, aliases?: string[][]): string {
435-
if (!aliases) {
436-
return commandLine;
437-
}
438-
for (const alias of aliases) {
439-
if (alias.length !== 2) {
440-
throw new Error('Not an alias');
441-
}
442-
commandLine.replaceAll(alias[0], alias[1]);
443-
}
444-
return commandLine;
445-
}

src/vs/workbench/contrib/terminal/common/terminal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import { Event } from 'vs/base/common/event';
88
import { IDisposable } from 'vs/base/common/lifecycle';
99
import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
1010
import { IExtensionPointDescriptor } from 'vs/workbench/services/extensions/common/extensionsRegistry';
11-
import { IProcessDataEvent, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalLaunchError, ITerminalProfile, ITerminalProfileObject, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalIcon, TerminalLocationString, IProcessProperty, TitleEventSource, ProcessPropertyType, IFixedTerminalDimensions, IExtensionTerminalProfile, ICreateContributedTerminalProfileOptions, IProcessPropertyMap, ITerminalEnvironment, ITerminalProcessOptions } from 'vs/platform/terminal/common/terminal';
11+
import { IProcessDataEvent, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalLaunchError, ITerminalProfile, ITerminalProfileObject, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalIcon, TerminalLocationString, IProcessProperty, TitleEventSource, ProcessPropertyType, IFixedTerminalDimensions, IExtensionTerminalProfile, ICreateContributedTerminalProfileOptions, IProcessPropertyMap, ITerminalEnvironment, ITerminalProcessOptions, ITerminalContributions } from 'vs/platform/terminal/common/terminal';
1212
import { IEnvironmentVariableInfo } from 'vs/workbench/contrib/terminal/common/environmentVariable';
1313
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
1414
import { URI } from 'vs/base/common/uri';
1515
import { Registry } from 'vs/platform/registry/common/platform';
1616
import { IMarkProperties, ISerializedCommandDetectionCapability, ITerminalCapabilityStore, IXtermMarker } from 'vs/platform/terminal/common/capabilities/capabilities';
1717
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
1818
import { IProcessDetails } from 'vs/platform/terminal/common/terminalProcess';
19-
import { ITerminalQuickFixProvider, ITerminalCommandSelector, ITerminalOutputMatch, ITerminalOutputMatcher, ITerminalContributions } from 'vs/platform/terminal/common/xterm/terminalQuickFix';
19+
import { ITerminalQuickFixProvider, ITerminalCommandSelector, ITerminalOutputMatch, ITerminalOutputMatcher } from 'vs/platform/terminal/common/xterm/terminalQuickFix';
2020

2121
export const TERMINAL_VIEW_ID = 'terminal';
2222

0 commit comments

Comments
 (0)