@@ -46,7 +46,7 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag
46
46
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
47
47
import { ITerminalCommand , TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities' ;
48
48
import { TerminalCapabilityStoreMultiplexer } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore' ;
49
- import { IProcessDataEvent , IProcessPropertyMap , IShellLaunchConfig , ITerminalDimensionsOverride , ITerminalLaunchError , PosixShellType , ProcessPropertyType , TerminalIcon , TerminalLocation , TerminalSettingId , TerminalShellType , TitleEventSource , WindowsShellType } from 'vs/platform/terminal/common/terminal' ;
49
+ import { IProcessDataEvent , IProcessPropertyMap , IShellLaunchConfig , ITerminalDimensionsOverride , ITerminalLaunchError , PosixShellType , ProcessPropertyType , ShellIntegrationStatus , TerminalIcon , TerminalLocation , TerminalSettingId , TerminalShellType , TitleEventSource , WindowsShellType } from 'vs/platform/terminal/common/terminal' ;
50
50
import { escapeNonWindowsPath , collapseTildePath } from 'vs/platform/terminal/common/terminalEnvironment' ;
51
51
import { activeContrastBorder , scrollbarSliderActiveBackground , scrollbarSliderBackground , scrollbarSliderHoverBackground } from 'vs/platform/theme/common/colorRegistry' ;
52
52
import { IColorTheme , ICssStyleCollector , IThemeService , registerThemingParticipant , ThemeIcon } from 'vs/platform/theme/common/themeService' ;
@@ -356,6 +356,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
356
356
private readonly _terminalShellTypeContextKey : IContextKey < string > ,
357
357
private readonly _terminalAltBufferActiveContextKey : IContextKey < boolean > ,
358
358
private readonly _terminalInRunCommandPicker : IContextKey < boolean > ,
359
+ private readonly _terminalShellIntegrationEnabledContextKey : IContextKey < boolean > ,
359
360
private readonly _configHelper : TerminalConfigHelper ,
360
361
private _shellLaunchConfig : IShellLaunchConfig ,
361
362
resource : URI | undefined ,
@@ -1083,6 +1084,13 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1083
1084
const screenElement = xterm . attachToElement ( xtermElement ) ;
1084
1085
1085
1086
xterm . onDidChangeFindResults ( ( results ) => this . _onDidChangeFindResults . fire ( results ) ) ;
1087
+ xterm . shellIntegration . onDidChangeStatus ( ( ) => {
1088
+ if ( this . hasFocus ) {
1089
+ this . _setShellIntegrationContextKey ( ) ;
1090
+ } else {
1091
+ this . _terminalShellIntegrationEnabledContextKey . reset ( ) ;
1092
+ }
1093
+ } ) ;
1086
1094
1087
1095
if ( ! xterm . raw . element || ! xterm . raw . textarea ) {
1088
1096
throw new Error ( 'xterm elements not set after open' ) ;
@@ -1216,16 +1224,25 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1216
1224
private _setFocus ( focused ?: boolean ) : void {
1217
1225
if ( focused ) {
1218
1226
this . _terminalFocusContextKey . set ( true ) ;
1227
+ this . _setShellIntegrationContextKey ( ) ;
1219
1228
this . _onDidFocus . fire ( this ) ;
1220
1229
} else {
1221
- this . _terminalFocusContextKey . reset ( ) ;
1230
+ this . resetFocusContextKey ( ) ;
1222
1231
this . _onDidBlur . fire ( this ) ;
1223
1232
this . _refreshSelectionContextKey ( ) ;
1224
1233
}
1225
1234
}
1226
1235
1236
+ private _setShellIntegrationContextKey ( ) : void {
1237
+ console . log ( 'set' , this . xterm ?. shellIntegration . status === ShellIntegrationStatus . VSCode ) ;
1238
+ if ( this . xterm ) {
1239
+ this . _terminalShellIntegrationEnabledContextKey . set ( this . xterm . shellIntegration . status === ShellIntegrationStatus . VSCode ) ;
1240
+ }
1241
+ }
1242
+
1227
1243
resetFocusContextKey ( ) : void {
1228
1244
this . _terminalFocusContextKey . reset ( ) ;
1245
+ this . _terminalShellIntegrationEnabledContextKey . reset ( ) ;
1229
1246
}
1230
1247
1231
1248
private _initDragAndDrop ( container : HTMLElement ) {
@@ -1301,6 +1318,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1301
1318
}
1302
1319
const terminalFocused = ! isFocused && ( document . activeElement === this . xterm . raw . textarea || document . activeElement === this . xterm . raw . element ) ;
1303
1320
this . _terminalFocusContextKey . set ( terminalFocused ) ;
1321
+ if ( terminalFocused ) {
1322
+ this . _setShellIntegrationContextKey ( ) ;
1323
+ } else {
1324
+ this . _terminalShellIntegrationEnabledContextKey . reset ( ) ;
1325
+ }
1304
1326
}
1305
1327
1306
1328
private _refreshAltBufferContextKey ( ) {
@@ -1381,7 +1403,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1381
1403
// as 'blur' event in xterm.raw.textarea is not triggered on xterm.dispose()
1382
1404
// See https://github.com/microsoft/vscode/issues/138358
1383
1405
if ( isFirefox ) {
1384
- this . _terminalFocusContextKey . reset ( ) ;
1406
+ this . resetFocusContextKey ( ) ;
1385
1407
this . _terminalHasTextContextKey . reset ( ) ;
1386
1408
this . _onDidBlur . fire ( this ) ;
1387
1409
}
0 commit comments