mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 09:10:30 -04:00
Merge from vscode 6e530127a1bb8ffbd1bfb77dc680c321dc0d71f5 (#6844)
This commit is contained in:
@@ -298,6 +298,11 @@ configurationRegistry.registerConfiguration({
|
||||
description: nls.localize('terminal.integrated.experimentalRefreshOnResume', "An experimental setting that will refresh the terminal renderer when the system is resumed."),
|
||||
type: 'boolean',
|
||||
default: false
|
||||
},
|
||||
'terminal.integrated.experimentalUseTitleEvent': {
|
||||
description: nls.localize('terminal.integrated.experimentalUseTitleEvent', "An experimental setting that will use the terminal title event for the dropdown title. This setting will only apply to new terminals."),
|
||||
type: 'boolean',
|
||||
default: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
import { EndOfLinePreference } from 'vs/editor/common/model';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { ITerminalService, TERMINAL_PANEL_ID, ITerminalInstance, Direction, ITerminalConfigHelper } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ITerminalService, TERMINAL_PANEL_ID, ITerminalInstance, Direction, ITerminalConfigHelper, TitleEventSource } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { SelectActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { TogglePanelAction } from 'vs/workbench/browser/panel';
|
||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
@@ -1034,7 +1034,7 @@ export class RenameTerminalAction extends Action {
|
||||
prompt: nls.localize('workbench.action.terminal.rename.prompt', "Enter terminal name"),
|
||||
}).then(name => {
|
||||
if (name) {
|
||||
terminalInstance.setTitle(name, false);
|
||||
terminalInstance.setTitle(name, TitleEventSource.Api);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import { activeContrastBorder, scrollbarSliderActiveBackground, scrollbarSliderB
|
||||
import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { PANEL_BACKGROUND } from 'vs/workbench/common/theme';
|
||||
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/terminalWidgetManager';
|
||||
import { IShellLaunchConfig, ITerminalDimensions, ITerminalInstance, ITerminalProcessManager, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, ProcessState, TERMINAL_PANEL_ID, IWindowsShellHelper, SHELL_PATH_INVALID_EXIT_CODE, SHELL_PATH_DIRECTORY_EXIT_CODE, SHELL_CWD_INVALID_EXIT_CODE, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, INavigationMode } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { IShellLaunchConfig, ITerminalDimensions, ITerminalInstance, ITerminalProcessManager, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, ProcessState, TERMINAL_PANEL_ID, IWindowsShellHelper, SHELL_PATH_INVALID_EXIT_CODE, SHELL_PATH_DIRECTORY_EXIT_CODE, SHELL_CWD_INVALID_EXIT_CODE, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, INavigationMode, TitleEventSource } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
|
||||
import { TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminalCommands';
|
||||
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
|
||||
@@ -973,11 +973,22 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
||||
this._processManager.onProcessResolvedShellLaunchConfig(e => this._setResolvedShellLaunchConfig(e));
|
||||
|
||||
if (this._shellLaunchConfig.name) {
|
||||
this.setTitle(this._shellLaunchConfig.name, false);
|
||||
this.setTitle(this._shellLaunchConfig.name, TitleEventSource.Api);
|
||||
} else {
|
||||
// Only listen for process title changes when a name is not provided
|
||||
this.setTitle(this._shellLaunchConfig.executable, true);
|
||||
this._messageTitleDisposable = this._processManager.onProcessTitle(title => this.setTitle(title ? title : '', true));
|
||||
if (this._configHelper.config.experimentalUseTitleEvent) {
|
||||
this._processManager.ptyProcessReady.then(() => {
|
||||
this._terminalInstanceService.getDefaultShellAndArgs(false).then(e => {
|
||||
this.setTitle(e.shell, TitleEventSource.Sequence);
|
||||
});
|
||||
this._xtermReadyPromise.then(xterm => {
|
||||
this._messageTitleDisposable = xterm.onTitleChange(e => this._onTitleChange(e));
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.setTitle(this._shellLaunchConfig.executable, TitleEventSource.Process);
|
||||
this._messageTitleDisposable = this._processManager.onProcessTitle(title => this.setTitle(title ? title : '', TitleEventSource.Process));
|
||||
}
|
||||
}
|
||||
|
||||
if (platform.isWindows) {
|
||||
@@ -1149,7 +1160,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
||||
this._createProcess();
|
||||
|
||||
if (oldTitle !== this._title) {
|
||||
this.setTitle(this._title, true);
|
||||
this.setTitle(this._title, TitleEventSource.Process);
|
||||
}
|
||||
|
||||
this._processManager.onProcessData(data => this._onProcessData(data));
|
||||
@@ -1168,6 +1179,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
||||
this._sendLineData(buffer, buffer.baseY + buffer.cursorY);
|
||||
}
|
||||
|
||||
private _onTitleChange(title: string): void {
|
||||
if (this.isTitleSetByProcess) {
|
||||
this.setTitle(title, TitleEventSource.Sequence);
|
||||
}
|
||||
}
|
||||
|
||||
private _sendLineData(buffer: IBuffer, lineIndex: number): void {
|
||||
let line = buffer.getLine(lineIndex);
|
||||
if (!line) {
|
||||
@@ -1348,23 +1365,26 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
||||
this._processManager.ptyProcessReady.then(() => this._processManager.setDimensions(cols, rows));
|
||||
}
|
||||
|
||||
public setTitle(title: string | undefined, eventFromProcess: boolean): void {
|
||||
public setTitle(title: string | undefined, eventSource: TitleEventSource): void {
|
||||
if (!title) {
|
||||
return;
|
||||
}
|
||||
if (eventFromProcess) {
|
||||
title = path.basename(title);
|
||||
if (platform.isWindows) {
|
||||
// Remove the .exe extension
|
||||
title = title.split('.exe')[0];
|
||||
}
|
||||
} else {
|
||||
// If the title has not been set by the API or the rename command, unregister the handler that
|
||||
// automatically updates the terminal name
|
||||
dispose(this._messageTitleDisposable);
|
||||
this._messageTitleDisposable = undefined;
|
||||
dispose(this._windowsShellHelper);
|
||||
this._windowsShellHelper = undefined;
|
||||
switch (eventSource) {
|
||||
case TitleEventSource.Process:
|
||||
title = path.basename(title);
|
||||
if (platform.isWindows) {
|
||||
// Remove the .exe extension
|
||||
title = title.split('.exe')[0];
|
||||
}
|
||||
break;
|
||||
case TitleEventSource.Api:
|
||||
// If the title has not been set by the API or the rename command, unregister the handler that
|
||||
// automatically updates the terminal name
|
||||
dispose(this._messageTitleDisposable);
|
||||
this._messageTitleDisposable = undefined;
|
||||
dispose(this._windowsShellHelper);
|
||||
this._windowsShellHelper = undefined;
|
||||
break;
|
||||
}
|
||||
const didTitleChange = title !== this._title;
|
||||
this._title = title;
|
||||
|
||||
@@ -276,7 +276,7 @@ export class TerminalPanel extends Panel {
|
||||
const resources = e.dataTransfer.getData(DataTransfers.RESOURCES);
|
||||
if (resources) {
|
||||
path = URI.parse(JSON.parse(resources)[0]).fsPath;
|
||||
} else if (e.dataTransfer.files.length > 0) {
|
||||
} else if (e.dataTransfer.files.length > 0 && e.dataTransfer.files[0].path /* Electron only */) {
|
||||
// Check if the file was dragged from the filesystem
|
||||
path = URI.file(e.dataTransfer.files[0].path).fsPath;
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ export interface ITerminalConfiguration {
|
||||
splitCwd: 'workspaceRoot' | 'initial' | 'inherited';
|
||||
windowsEnableConpty: boolean;
|
||||
experimentalRefreshOnResume: boolean;
|
||||
experimentalUseTitleEvent: boolean;
|
||||
}
|
||||
|
||||
export interface ITerminalConfigHelper {
|
||||
@@ -636,7 +637,7 @@ export interface ITerminalInstance {
|
||||
/**
|
||||
* Sets the title of the terminal instance.
|
||||
*/
|
||||
setTitle(title: string, eventFromProcess: boolean): void;
|
||||
setTitle(title: string, eventSource: TitleEventSource): void;
|
||||
|
||||
waitForTitle(): Promise<string>;
|
||||
|
||||
@@ -769,6 +770,15 @@ export enum LinuxDistro {
|
||||
Unknown
|
||||
}
|
||||
|
||||
export enum TitleEventSource {
|
||||
/** From the API or the rename command that overrides any other type */
|
||||
Api,
|
||||
/** From the process name property*/
|
||||
Process,
|
||||
/** From the VT sequence */
|
||||
Sequence
|
||||
}
|
||||
|
||||
export interface IWindowsShellHelper extends IDisposable {
|
||||
getShellName(): Promise<string>;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export function addTerminalEnvironmentKeys(env: platform.IProcessEnvironment, ve
|
||||
env['COLORTERM'] = 'truecolor';
|
||||
}
|
||||
|
||||
function mergeNonNullKeys(env: platform.IProcessEnvironment, other: ITerminalEnvironment | NodeJS.ProcessEnv | undefined) {
|
||||
function mergeNonNullKeys(env: platform.IProcessEnvironment, other: ITerminalEnvironment | undefined) {
|
||||
if (!other) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { TERMINAL_ACTION_CATEGORY, ITerminalService } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { TERMINAL_ACTION_CATEGORY, ITerminalService, TitleEventSource } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminalCommands';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
@@ -39,7 +39,7 @@ export class CreateNewLocalTerminalAction extends Action {
|
||||
const disposable = instance.onTitleChanged(() => {
|
||||
if (instance.title && instance.title.trim().length > 0) {
|
||||
disposable.dispose();
|
||||
instance.setTitle(`${instance.title} (Local)`, false);
|
||||
instance.setTitle(`${instance.title} (Local)`, TitleEventSource.Api);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { ITerminalInstance, IWindowsShellHelper } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ITerminalInstance, IWindowsShellHelper, TitleEventSource } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { Terminal as XTermTerminal } from 'xterm';
|
||||
import WindowsProcessTreeType = require('windows-process-tree');
|
||||
import * as WindowsProcessTreeType from 'windows-process-tree';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
const SHELL_EXECUTABLES = [
|
||||
@@ -80,7 +80,7 @@ export class WindowsShellHelper extends Disposable implements IWindowsShellHelpe
|
||||
if (platform.isWindows && this._terminalInstance.isTitleSetByProcess) {
|
||||
this.getShellName().then(title => {
|
||||
if (!this._isDisposed) {
|
||||
this._terminalInstance.setTitle(title, true);
|
||||
this._terminalInstance.setTitle(title, TitleEventSource.Process);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user