From 8a82ce7495d5adfecf74e6a4c0cc039d4ca9771d Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 7 Aug 2024 11:28:24 -0700 Subject: [PATCH 1/6] Start adding Julia as Shell type --- src/vs/platform/terminal/common/terminal.ts | 8 ++++++-- src/vs/platform/terminal/node/terminalProcess.ts | 5 +++++ src/vs/platform/terminal/node/windowsShellHelper.ts | 2 ++ .../workbench/contrib/terminal/browser/terminalService.ts | 7 +++++-- src/vs/workbench/contrib/terminal/common/history.ts | 2 ++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index a7480bb99b984..6c29915e45212 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -135,14 +135,18 @@ export const enum PosixShellType { Csh = 'csh', Ksh = 'ksh', Zsh = 'zsh', - Python = 'python' + Python = 'python', + // TODO: Julia + Julia = 'julia' } export const enum WindowsShellType { CommandPrompt = 'cmd', PowerShell = 'pwsh', Wsl = 'wsl', GitBash = 'gitbash', - Python = 'python' + Python = 'python', + // TODO: Julia + Julia = 'julia' } export type TerminalShellType = PosixShellType | WindowsShellType; diff --git a/src/vs/platform/terminal/node/terminalProcess.ts b/src/vs/platform/terminal/node/terminalProcess.ts index e08cd21dc7b90..e77b09d66d8df 100644 --- a/src/vs/platform/terminal/node/terminalProcess.ts +++ b/src/vs/platform/terminal/node/terminalProcess.ts @@ -74,6 +74,8 @@ const posixShellTypeMap = new Map([ ['sh', PosixShellType.Sh], ['pwsh', PosixShellType.PowerShell], ['python', PosixShellType.Python], + // TODO: Julia + ['julia', PosixShellType.Julia], ['zsh', PosixShellType.Zsh] ]); @@ -411,7 +413,10 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess if (sanitizedTitle.toLowerCase().startsWith('python')) { this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: PosixShellType.Python }); + } else if (sanitizedTitle.toLowerCase().startsWith('julia')) { // TODO: not able to get it set here. + this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: PosixShellType.Julia }); } else { + //TODO: Make sure Julia gets handled correctly this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: posixShellTypeMap.get(sanitizedTitle) }); } } diff --git a/src/vs/platform/terminal/node/windowsShellHelper.ts b/src/vs/platform/terminal/node/windowsShellHelper.ts index e9fcb6f8130d7..206945102c544 100644 --- a/src/vs/platform/terminal/node/windowsShellHelper.ts +++ b/src/vs/platform/terminal/node/windowsShellHelper.ts @@ -150,6 +150,8 @@ export class WindowsShellHelper extends Disposable implements IWindowsShellHelpe case 'debian.exe': case 'opensuse-42.exe': case 'sles-12.exe': + // TODO: Julia executable + return WindowsShellType.Wsl; default: if (executable.match(/python(\d(\.\d{0,2})?)?\.exe/)) { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index 2dc85842d94cf..ded75cdc5ab83 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -19,7 +19,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { INotificationService } from 'vs/platform/notification/common/notification'; -import { ICreateContributedTerminalProfileOptions, IExtensionTerminalProfile, IPtyHostAttachTarget, IRawTerminalInstanceLayoutInfo, IRawTerminalTabLayoutInfo, IShellLaunchConfig, ITerminalBackend, ITerminalLaunchError, ITerminalLogService, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalExitReason, TerminalLocation, TerminalLocationString, TitleEventSource } from 'vs/platform/terminal/common/terminal'; +import { ICreateContributedTerminalProfileOptions, IExtensionTerminalProfile, IPtyHostAttachTarget, IRawTerminalInstanceLayoutInfo, IRawTerminalTabLayoutInfo, IShellLaunchConfig, ITerminalBackend, ITerminalLaunchError, ITerminalLogService, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, PosixShellType, TerminalExitReason, TerminalLocation, TerminalLocationString, TitleEventSource } from 'vs/platform/terminal/common/terminal'; import { formatMessageForTerminal } from 'vs/platform/terminal/common/terminalStrings'; import { iconForeground } from 'vs/platform/theme/common/colorRegistry'; import { getIconRegistry } from 'vs/platform/theme/common/iconRegistry'; @@ -208,7 +208,10 @@ export class TerminalService extends Disposable implements ITerminalService { } if (instance?.shellType) { this._terminalShellTypeContextKey.set(instance.shellType.toString()); - } else if (!instance || !(instance.shellType)) { + } else if (instance?.title.includes('Julia')) { + this._terminalShellTypeContextKey.set(PosixShellType.Julia.toString()); + + } else if (!instance) { this._terminalShellTypeContextKey.reset(); } })); diff --git a/src/vs/workbench/contrib/terminal/common/history.ts b/src/vs/workbench/contrib/terminal/common/history.ts index 390d66980a4de..eda5fa368974d 100644 --- a/src/vs/workbench/contrib/terminal/common/history.ts +++ b/src/vs/workbench/contrib/terminal/common/history.ts @@ -95,6 +95,8 @@ export async function getShellFileHistory(accessor: ServicesAccessor, shellType: case PosixShellType.Python: result = await fetchPythonHistory(accessor); break; + // Should there by one for Julia, how are they able to insert command into run recent history. + default: return []; } if (result === undefined) { From 73a501085f8e4a53c3c571a8ee2b29edea95675f Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 7 Aug 2024 15:22:34 -0700 Subject: [PATCH 2/6] remove unncessary --- src/vs/platform/terminal/node/terminalProcess.ts | 2 +- src/vs/workbench/contrib/terminal/browser/terminalService.ts | 3 --- src/vs/workbench/contrib/terminal/common/history.ts | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/vs/platform/terminal/node/terminalProcess.ts b/src/vs/platform/terminal/node/terminalProcess.ts index e77b09d66d8df..8caa9c86d3e41 100644 --- a/src/vs/platform/terminal/node/terminalProcess.ts +++ b/src/vs/platform/terminal/node/terminalProcess.ts @@ -413,7 +413,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess if (sanitizedTitle.toLowerCase().startsWith('python')) { this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: PosixShellType.Python }); - } else if (sanitizedTitle.toLowerCase().startsWith('julia')) { // TODO: not able to get it set here. + } else if (sanitizedTitle.toLowerCase().startsWith('julia')) { this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: PosixShellType.Julia }); } else { //TODO: Make sure Julia gets handled correctly diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index ded75cdc5ab83..d8d70c527fbd6 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -208,9 +208,6 @@ export class TerminalService extends Disposable implements ITerminalService { } if (instance?.shellType) { this._terminalShellTypeContextKey.set(instance.shellType.toString()); - } else if (instance?.title.includes('Julia')) { - this._terminalShellTypeContextKey.set(PosixShellType.Julia.toString()); - } else if (!instance) { this._terminalShellTypeContextKey.reset(); } diff --git a/src/vs/workbench/contrib/terminal/common/history.ts b/src/vs/workbench/contrib/terminal/common/history.ts index eda5fa368974d..26a81c5a7ed23 100644 --- a/src/vs/workbench/contrib/terminal/common/history.ts +++ b/src/vs/workbench/contrib/terminal/common/history.ts @@ -95,7 +95,6 @@ export async function getShellFileHistory(accessor: ServicesAccessor, shellType: case PosixShellType.Python: result = await fetchPythonHistory(accessor); break; - // Should there by one for Julia, how are they able to insert command into run recent history. default: return []; } From b731baed848b664663868adf87c39ba931e88228 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 7 Aug 2024 15:51:02 -0700 Subject: [PATCH 3/6] dont touch original --- src/vs/workbench/contrib/terminal/browser/terminalService.ts | 4 ++-- src/vs/workbench/contrib/terminal/common/history.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalService.ts b/src/vs/workbench/contrib/terminal/browser/terminalService.ts index d8d70c527fbd6..2dc85842d94cf 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalService.ts @@ -19,7 +19,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { INotificationService } from 'vs/platform/notification/common/notification'; -import { ICreateContributedTerminalProfileOptions, IExtensionTerminalProfile, IPtyHostAttachTarget, IRawTerminalInstanceLayoutInfo, IRawTerminalTabLayoutInfo, IShellLaunchConfig, ITerminalBackend, ITerminalLaunchError, ITerminalLogService, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, PosixShellType, TerminalExitReason, TerminalLocation, TerminalLocationString, TitleEventSource } from 'vs/platform/terminal/common/terminal'; +import { ICreateContributedTerminalProfileOptions, IExtensionTerminalProfile, IPtyHostAttachTarget, IRawTerminalInstanceLayoutInfo, IRawTerminalTabLayoutInfo, IShellLaunchConfig, ITerminalBackend, ITerminalLaunchError, ITerminalLogService, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalExitReason, TerminalLocation, TerminalLocationString, TitleEventSource } from 'vs/platform/terminal/common/terminal'; import { formatMessageForTerminal } from 'vs/platform/terminal/common/terminalStrings'; import { iconForeground } from 'vs/platform/theme/common/colorRegistry'; import { getIconRegistry } from 'vs/platform/theme/common/iconRegistry'; @@ -208,7 +208,7 @@ export class TerminalService extends Disposable implements ITerminalService { } if (instance?.shellType) { this._terminalShellTypeContextKey.set(instance.shellType.toString()); - } else if (!instance) { + } else if (!instance || !(instance.shellType)) { this._terminalShellTypeContextKey.reset(); } })); diff --git a/src/vs/workbench/contrib/terminal/common/history.ts b/src/vs/workbench/contrib/terminal/common/history.ts index 26a81c5a7ed23..390d66980a4de 100644 --- a/src/vs/workbench/contrib/terminal/common/history.ts +++ b/src/vs/workbench/contrib/terminal/common/history.ts @@ -95,7 +95,6 @@ export async function getShellFileHistory(accessor: ServicesAccessor, shellType: case PosixShellType.Python: result = await fetchPythonHistory(accessor); break; - default: return []; } if (result === undefined) { From 354040b085a6b682449eded85095a7fa43e956d3 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 7 Aug 2024 23:53:00 -0700 Subject: [PATCH 4/6] add julia.exe to windowsShellHelper & clean up --- src/vs/platform/terminal/common/terminal.ts | 1 - src/vs/platform/terminal/node/terminalProcess.ts | 2 -- src/vs/platform/terminal/node/windowsShellHelper.ts | 3 ++- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index 6c29915e45212..e6a6d3061a48e 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -145,7 +145,6 @@ export const enum WindowsShellType { Wsl = 'wsl', GitBash = 'gitbash', Python = 'python', - // TODO: Julia Julia = 'julia' } export type TerminalShellType = PosixShellType | WindowsShellType; diff --git a/src/vs/platform/terminal/node/terminalProcess.ts b/src/vs/platform/terminal/node/terminalProcess.ts index 8caa9c86d3e41..b4b28d9ad78ae 100644 --- a/src/vs/platform/terminal/node/terminalProcess.ts +++ b/src/vs/platform/terminal/node/terminalProcess.ts @@ -74,7 +74,6 @@ const posixShellTypeMap = new Map([ ['sh', PosixShellType.Sh], ['pwsh', PosixShellType.PowerShell], ['python', PosixShellType.Python], - // TODO: Julia ['julia', PosixShellType.Julia], ['zsh', PosixShellType.Zsh] ]); @@ -416,7 +415,6 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess } else if (sanitizedTitle.toLowerCase().startsWith('julia')) { this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: PosixShellType.Julia }); } else { - //TODO: Make sure Julia gets handled correctly this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: posixShellTypeMap.get(sanitizedTitle) }); } } diff --git a/src/vs/platform/terminal/node/windowsShellHelper.ts b/src/vs/platform/terminal/node/windowsShellHelper.ts index 206945102c544..455944dc75024 100644 --- a/src/vs/platform/terminal/node/windowsShellHelper.ts +++ b/src/vs/platform/terminal/node/windowsShellHelper.ts @@ -143,6 +143,8 @@ export class WindowsShellHelper extends Disposable implements IWindowsShellHelpe case 'bash.exe': case 'git-cmd.exe': return WindowsShellType.GitBash; + case 'julia.exe:': + return WindowsShellType.Julia; case 'wsl.exe': case 'ubuntu.exe': case 'ubuntu1804.exe': @@ -150,7 +152,6 @@ export class WindowsShellHelper extends Disposable implements IWindowsShellHelpe case 'debian.exe': case 'opensuse-42.exe': case 'sles-12.exe': - // TODO: Julia executable return WindowsShellType.Wsl; default: From 497e93f4cd79810f4f9723a328488eb30e06778e Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 8 Aug 2024 13:20:47 -0700 Subject: [PATCH 5/6] remove completed TODO --- src/vs/platform/terminal/common/terminal.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index e6a6d3061a48e..c90aca15a2062 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -136,7 +136,6 @@ export const enum PosixShellType { Ksh = 'ksh', Zsh = 'zsh', Python = 'python', - // TODO: Julia Julia = 'julia' } export const enum WindowsShellType { From 9e3a5b2f824cc489475a2c3b3b2c7907bd9725e8 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 8 Aug 2024 13:22:36 -0700 Subject: [PATCH 6/6] format --- src/vs/platform/terminal/node/windowsShellHelper.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/platform/terminal/node/windowsShellHelper.ts b/src/vs/platform/terminal/node/windowsShellHelper.ts index 455944dc75024..5792455b0ae05 100644 --- a/src/vs/platform/terminal/node/windowsShellHelper.ts +++ b/src/vs/platform/terminal/node/windowsShellHelper.ts @@ -152,7 +152,6 @@ export class WindowsShellHelper extends Disposable implements IWindowsShellHelpe case 'debian.exe': case 'opensuse-42.exe': case 'sles-12.exe': - return WindowsShellType.Wsl; default: if (executable.match(/python(\d(\.\d{0,2})?)?\.exe/)) {