Revert "Revert "Merge from vscode ada4bddb8edc69eea6ebaaa0e88c5f903cbd43d8 (#5529)" (#5553)" (#5562)

This reverts commit c9a4f8f664.
This commit is contained in:
Anthony Dresser
2019-05-21 14:19:32 -07:00
committed by GitHub
parent 7670104e4d
commit 81ae86ff79
325 changed files with 4497 additions and 3328 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ exports.base = [{
}];
exports.workbench = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.main']);
exports.workbenchNodeless = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.nodeless.main']);
exports.workbenchWeb = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.web.main']);
exports.code = require('./vs/code/buildfile').collectModules();
@@ -14,7 +14,7 @@
background: url('check.svg') center center no-repeat;
}
.vs-dark.monaco-shell .custom-checkbox.sql-checkbox.checked {
.vs-dark .custom-checkbox.sql-checkbox.checked {
background: url('check_inverse.svg') center center no-repeat;
}
+11 -11
View File
@@ -7,8 +7,8 @@ import { IAction, IActionRunner, ActionRunner } from 'vs/base/common/actions';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import {
IActionBarOptions, ActionsOrientation, IActionItem,
IActionOptions, ActionItem, BaseActionItem
IActionBarOptions, ActionsOrientation, IActionViewItem,
IActionOptions, ActionViewItem, BaseActionViewItem
} from 'vs/base/browser/ui/actionbar/actionbar';
import * as lifecycle from 'vs/base/common/lifecycle';
import * as DOM from 'vs/base/browser/dom';
@@ -31,7 +31,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
private _context: any;
// Items
private _items: IActionItem[];
private _items: IActionViewItem[];
private _focusedItem?: number;
private _focusTracker: DOM.IFocusTracker;
@@ -214,14 +214,14 @@ export class ActionBar extends ActionRunner implements IActionRunner {
actionItemElement.className = 'action-item';
actionItemElement.setAttribute('role', 'presentation');
let item: IActionItem | undefined = undefined;
let item: IActionViewItem | undefined = undefined;
if (this._options.actionItemProvider) {
item = this._options.actionItemProvider(action);
if (this._options.actionViewItemProvider) {
item = this._options.actionViewItemProvider(action);
}
if (!item) {
item = new ActionItem(this.context, action, options);
item = new ActionViewItem(this.context, action, options);
}
item.actionRunner = this._actionRunner;
@@ -248,7 +248,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
public clear(): void {
// Do not dispose action items if they were provided from outside
this._items = this._options.actionItemProvider ? [] : lifecycle.dispose(this._items);
this._items = this._options.actionViewItemProvider ? [] : lifecycle.dispose(this._items);
DOM.clearNode(this._actionsList);
}
@@ -274,7 +274,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
}
let startIndex = this._focusedItem;
let item: IActionItem;
let item: IActionViewItem;
do {
this._focusedItem = (this._focusedItem + 1) % this._items.length;
@@ -294,7 +294,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
}
let startIndex = this._focusedItem;
let item: IActionItem;
let item: IActionViewItem;
do {
this._focusedItem = this._focusedItem - 1;
@@ -343,7 +343,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
// trigger action
let actionItem = this._items[this._focusedItem];
if (actionItem instanceof BaseActionItem) {
if (actionItem instanceof BaseActionViewItem) {
const context = (actionItem._context === null || actionItem._context === undefined) ? event : actionItem._context;
this.run(actionItem._action, context);
}
+2 -2
View File
@@ -43,8 +43,8 @@ export class Taskbar {
this.actionBar = new ActionBar(element, {
orientation: options.orientation,
ariaLabel: options.ariaLabel,
actionItemProvider: (action: Action) => {
return options.actionItemProvider ? options.actionItemProvider(action) : undefined;
actionViewItemProvider: (action: Action) => {
return options.actionViewItemProvider ? options.actionViewItemProvider(action) : undefined;
}
});
}
@@ -397,7 +397,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
let isUntitled: boolean = uri.scheme === Schemas.untitled;
const fileInput = isUntitled ? this._untitledEditorService.createOrGet(uri, notebookModeId, options.initialContent) :
this._editorService.createInput({ resource: uri, language: notebookModeId });
this._editorService.createInput({ resource: uri, mode: notebookModeId });
let input = this._instantiationService.createInstance(NotebookInput, path.basename(uri.fsPath), uri, fileInput);
input.defaultKernel = options.defaultKernel;
input.connectionProfile = new ConnectionProfile(this._capabilitiesService, options.connectionProfile);
+10 -11
View File
@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.monaco-shell .modal {
.modal {
background-color: rgba(204, 204, 204, 0.6);
right: 0;
left: 0;
@@ -13,7 +13,7 @@
z-index: 500;
}
.monaco-shell .modal:not(.flyout-dialog) .modal-dialog {
.modal:not(.flyout-dialog) .modal-dialog {
margin: auto;
width: 640px;
height: 480px;
@@ -32,7 +32,7 @@
height: 25px;
}
.monaco-shell .modal.flyout-dialog .modal-dialog {
.modal.flyout-dialog .modal-dialog {
margin: auto auto auto auto;
height: 100%;
width: 500px;
@@ -40,14 +40,13 @@
position: absolute;
overflow-y: hidden;
}
.monaco-shell .modal.flyout-dialog.wide .modal-dialog {
.modal.flyout-dialog.wide .modal-dialog {
width: 1200px;
max-width: 95%;
min-width: 400px;
}
.monaco-shell .modal.flyout-dialog .modal-content {
.modal.flyout-dialog .modal-content {
height: 100%;
font-size: 11px;
display: flex;
@@ -66,10 +65,10 @@
margin-right: 10px;
}
.monaco-shell .modal.flyout-dialog .modal-body,
.monaco-shell .modal.flyout-dialog .angular-modal-body,
.modal.flyout-dialog .modal-body,
.modal.flyout-dialog .angular-modal-body,
/* Style for body and footer in modal dialog. This should be applied to dialog created with angular component. */
.monaco-shell .modal.flyout-dialog .modal-body-and-footer {
.modal.flyout-dialog .modal-body-and-footer {
flex: 1 1;
overflow: hidden;
}
@@ -105,11 +104,11 @@
padding-left: 4px;
}
.vs-dark.monaco-shell .modal.flyout-dialog .input {
.vs-dark .modal.flyout-dialog .input {
background-color: #3C3C3C;
}
.vs-dark.monaco-shell .modal.flyout-dialog input:disabled {
.vs-dark .modal.flyout-dialog input:disabled {
background-color: #E1E1E1;
color: #3C3C3C;
}
@@ -10,7 +10,6 @@ import { IAction, ActionRunner, Action } from 'vs/base/common/actions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { ContextAwareMenuItemActionItem, fillInActionBarActions, fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ViewContainer, ITreeItemLabel } from 'vs/workbench/common/views';
import { FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet';
@@ -22,7 +21,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import * as DOM from 'vs/base/browser/dom';
import { IDataSource, ITree, IRenderer, ContextMenuEvent } from 'vs/base/parts/tree/browser/tree';
import { ResourceLabel } from 'vs/workbench/browser/labels';
import { ActionBar, IActionItemProvider, ActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { ActionBar, IActionViewItemProvider, ActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { URI } from 'vs/base/common/uri';
import { basename } from 'vs/base/common/path';
import { LIGHT, FileThemeIcon, FolderThemeIcon, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
@@ -46,6 +45,7 @@ import { ITreeItem, ITreeView } from 'sql/workbench/common/views';
import { IOEShimService } from 'sql/workbench/parts/objectExplorer/common/objectExplorerViewTreeShim';
import { equalsIgnoreCase } from 'vs/base/common/strings';
import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/common/nodeContext';
import { fillInActionBarActions, fillInContextMenuActions, ContextAwareMenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
class TitleMenus implements IDisposable {
@@ -319,7 +319,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
}
private createTree() {
const actionItemProvider = (action: IAction) => action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuItemActionItem, action) : undefined;
const actionItemProvider = (action: IAction) => action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuEntryActionViewItem, action) : undefined;
const menus = this.instantiationService.createInstance(TreeMenus, this.id);
const dataSource = this.instantiationService.createInstance(TreeDataSource, this, this.container, this.id);
const renderer = this.instantiationService.createInstance(TreeRenderer, this.id, menus, actionItemProvider);
@@ -599,7 +599,7 @@ class TreeRenderer implements IRenderer {
constructor(
private treeViewId: string,
private menus: TreeMenus,
private actionItemProvider: IActionItemProvider,
private actionItemProvider: IActionViewItemProvider,
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkbenchThemeService private themeService: IWorkbenchThemeService,
@IConfigurationService private configurationService: IConfigurationService,
@@ -623,7 +623,7 @@ class TreeRenderer implements IRenderer {
DOM.addClass(resourceLabel.element.element, 'custom-view-tree-node-item-resourceLabel');
const actionsContainer = DOM.append(resourceLabel.element.element, DOM.$('.actions'));
const actionBar = new ActionBar(actionsContainer, {
actionItemProvider: this.actionItemProvider,
actionViewItemProvider: this.actionItemProvider,
actionRunner: new MultipleSelectionActionRunner(() => tree.getSelection())
});
@@ -769,10 +769,10 @@ class TreeController extends WorkbenchTreeController {
getActions: () => actions,
getActionItem: (action) => {
getActionViewItem: (action) => {
const keybinding = this._keybindingService.lookupKeybinding(action.id);
if (keybinding) {
return new ActionItem(action, action, { label: true, keybinding: keybinding.getLabel() });
return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() });
}
return null;
},
@@ -181,7 +181,7 @@ function getNotebookFileExtensions(instantiationService: IInstantiationService):
function hasNotebookFileMode(input: EditorInput): boolean {
if (input instanceof UntitledEditorInput) {
let untitledCast: UntitledEditorInput = <UntitledEditorInput>input;
return (untitledCast && untitledCast.getModeId() === notebookModeId);
return (untitledCast && untitledCast.getMode() === notebookModeId);
}
return false;
}
@@ -200,7 +200,7 @@ function withService<TService, TResult>(instantiationService: IInstantiationServ
function hasSqlFileMode(input: EditorInput): boolean {
if (input instanceof UntitledEditorInput) {
let untitledCast: UntitledEditorInput = <UntitledEditorInput>input;
return untitledCast && (untitledCast.getModeId() === undefined || untitledCast.getModeId() === sqlModeId);
return untitledCast && (untitledCast.getMode() === undefined || untitledCast.getMode() === sqlModeId);
}
return false;
@@ -94,7 +94,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen
private setHtml(): void {
if (this._webview && this.html) {
this._renderedHtml = this.html;
this._webview.contents = this._renderedHtml;
this._webview.html = this._renderedHtml;
this._webview.layout();
}
}
@@ -80,7 +80,7 @@ export class WebviewContent extends AngularDisposable implements OnInit, IDashbo
public setHtml(html: string): void {
this._html = html;
if (this._webview) {
this._webview.contents = html;
this._webview.html = html;
this._webview.layout();
}
}
@@ -112,7 +112,7 @@ export class WebviewContent extends AngularDisposable implements OnInit, IDashbo
this._onMessage.fire(e);
});
if (this._html) {
this._webview.contents = this._html;
this._webview.html = this._html;
}
this._webview.layout();
}
@@ -60,7 +60,7 @@ export class WebviewWidget extends DashboardWidget implements IDashboardWidget,
public setHtml(html: string): void {
this._html = html;
if (this._webview) {
this._webview.contents = html;
this._webview.html = html;
this._webview.layout();
}
}
@@ -110,7 +110,7 @@ export class WebviewWidget extends DashboardWidget implements IDashboardWidget,
this._onMessage.fire(e);
});
if (this._html) {
this._webview.contents = this._html;
this._webview.html = this._html;
}
this._webview.layout();
}
@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Action, IActionItem, IActionRunner } from 'vs/base/common/actions';
import { Action, IActionViewItem, IActionRunner } from 'vs/base/common/actions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IQueryModelService } from 'sql/platform/query/common/queryModel';
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
@@ -150,7 +150,7 @@ export class ChangeMaxRowsAction extends EditDataAction {
* Action item that handles the dropdown (combobox) that lists the avaliable number of row selections
* for an edit data session
*/
export class ChangeMaxRowsActionItem implements IActionItem {
export class ChangeMaxRowsActionItem implements IActionViewItem {
public actionRunner: IActionRunner;
public defaultRowCount: number;
@@ -19,7 +19,7 @@ import { EditDataInput } from 'sql/workbench/parts/editData/common/editDataInput
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import * as queryContext from 'sql/workbench/parts/query/common/queryContext';
import { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { Action } from 'vs/base/common/actions';
import { IQueryModelService } from 'sql/platform/query/common/queryModel';
import { IEditorDescriptorService } from 'sql/workbench/services/queryEditor/common/editorDescriptorService';
@@ -313,7 +313,7 @@ export class EditDataEditor extends BaseEditor {
// Create QueryTaskbar
this._taskbarContainer = DOM.append(parentElement, DOM.$('div'));
this._taskbar = new Taskbar(this._taskbarContainer, {
actionItemProvider: (action: Action) => this._getChangeMaxRowsAction(action)
actionViewItemProvider: (action: Action) => this._getChangeMaxRowsAction(action)
});
// Create Actions for the toolbar
@@ -344,7 +344,7 @@ export class EditDataEditor extends BaseEditor {
/**
* Gets the IActionItem for the list of row number drop down
*/
private _getChangeMaxRowsAction(action: Action): IActionItem {
private _getChangeMaxRowsAction(action: Action): IActionViewItem {
let actionID = ChangeMaxRowsAction.ID;
if (action.id === actionID) {
if (!this._changeMaxRowsActionItem) {
@@ -119,8 +119,8 @@ input#accordion:checked ~ .accordion-content {
padding-bottom: 10px;
}
.vs-dark.monaco-shell .all-jobs >.back-button-icon,
.hc-black.monaco-shell .all-jobs >.back-button-icon {
.vs-dark .all-jobs >.back-button-icon,
.hc-black .all-jobs >.back-button-icon {
content: url('back_inverse.svg');
}
@@ -14,10 +14,9 @@ import { IContextMenuService, IContextViewService } from 'vs/platform/contextvie
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
import { MenuId, IMenuService, MenuItemAction } from 'vs/platform/actions/common/actions';
import { IAction, Action, IActionItem } from 'vs/base/common/actions';
import { IAction, Action, IActionViewItem } from 'vs/base/common/actions';
import { IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { fillInActions, LabeledMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { AngularDisposable } from 'sql/base/node/lifecycle';
@@ -48,6 +47,7 @@ import { createErrorWithActions } from 'vs/base/common/errorsWithActions';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { ILogService } from 'vs/platform/log/common/log';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { LabeledMenuItemActionItem, fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
@@ -405,7 +405,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
this._trustedAction.enabled = false;
let taskbar = <HTMLElement>this.toolbar.nativeElement;
this._actionBar = new Taskbar(taskbar, { actionItemProvider: action => this.actionItemProvider(action as Action) });
this._actionBar = new Taskbar(taskbar, { actionViewItemProvider: action => this.actionItemProvider(action as Action) });
this._actionBar.context = this;
this._actionBar.setContent([
{ action: addCodeCellButton },
@@ -419,7 +419,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
}
private actionItemProvider(action: Action): IActionItem {
private actionItemProvider(action: Action): IActionViewItem {
// Check extensions to create ActionItem; otherwise, return undefined
// This is similar behavior that exists in MenuItemActionItem
if (action instanceof MenuItemAction) {
@@ -8,7 +8,6 @@ import { ContributableActionProvider } from 'vs/workbench/browser/actions';
import { IAction } from 'vs/base/common/actions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import {
DisconnectConnectionAction, AddServerAction,
@@ -31,6 +30,7 @@ import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/tr
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
/**
* Provides actions for the server tree elements
@@ -5,7 +5,7 @@
import 'vs/css!./media/queryActions';
import * as nls from 'vs/nls';
import { Action, IActionItem, IActionRunner } from 'vs/base/common/actions';
import { Action, IActionViewItem, IActionRunner } from 'vs/base/common/actions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -427,7 +427,7 @@ export class ListDatabasesAction extends QueryTaskbarAction {
* Action item that handles the dropdown (combobox) that lists the available databases.
* Based off StartDebugActionItem.
*/
export class ListDatabasesActionItem implements IActionItem {
export class ListDatabasesActionItem implements IActionViewItem {
public static ID = 'listDatabaseQueryActionItem';
public actionRunner: IActionRunner;
@@ -23,7 +23,7 @@ import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResour
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { Action } from 'vs/base/common/actions';
import { ISelectionData } from 'azdata';
import { IDisposable } from 'vs/base/common/lifecycle';
@@ -463,7 +463,7 @@ export class QueryEditor extends BaseEditor {
// Create QueryTaskbar
this._taskbarContainer = DOM.append(parentElement, DOM.$('div'));
this._taskbar = new Taskbar(this._taskbarContainer, {
actionItemProvider: (action: Action) => this._getActionItemForAction(action),
actionViewItemProvider: (action: Action) => this._getActionItemForAction(action),
});
// Create Actions for the toolbar
@@ -513,7 +513,7 @@ export class QueryEditor extends BaseEditor {
* Gets the IActionItem for the List Databases dropdown if provided the associated Action.
* Otherwise returns null.
*/
private _getActionItemForAction(action: Action): IActionItem {
private _getActionItemForAction(action: Action): IActionViewItem {
if (action.id === ListDatabasesAction.ID) {
return this.listDatabasesActionItem;
}
@@ -146,8 +146,11 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
// Description is shown beside the tab name in the combobox of open editors
public getDescription(): string { return this._description; }
public supportsSplitEditor(): boolean { return false; }
public getModeId(): string { return QueryInput.SCHEMA; }
public getMode(): string { return QueryInput.SCHEMA; }
public revert(): Promise<boolean> { return this._sql.revert(); }
public setMode(mode: string) {
this._sql.setMode(mode);
}
public matches(otherInput: any): boolean {
if (otherInput instanceof QueryInput) {
@@ -121,7 +121,7 @@ export class WebViewDialog extends Modal {
}
private updateDialogBody(): void {
this._webview.contents = this.html;
this._webview.html = this.html;
}
/* espace key */
@@ -303,7 +303,7 @@ export class QueryEditorService implements IQueryEditorService {
newEditorInput = queryInput;
} else {
let uriCopy: URI = URI.from({ scheme: uri.scheme, authority: uri.authority, path: uri.path, query: uri.query, fragment: uri.fragment });
newEditorInput = QueryEditorService.instantiationService.createInstance(FileEditorInput, uriCopy, undefined);
newEditorInput = QueryEditorService.instantiationService.createInstance(FileEditorInput, uriCopy, undefined, undefined);
}
return newEditorInput;
+303 -44
View File
@@ -101,17 +101,6 @@ declare module 'vscode-xterm' {
*/
experimentalCharAtlas?: 'none' | 'static' | 'dynamic';
/**
* (EXPERIMENTAL) Defines which implementation to use for buffer lines.
*
* - 'JsArray': The default/stable implementation.
* - 'TypedArray': The new experimental implementation based on TypedArrays that is expected to
* significantly boost performance and memory consumption. Use at your own risk.
*
* @deprecated This option will be removed in the future.
*/
experimentalBufferLineImpl?: 'JsArray' | 'TypedArray';
/**
* The font size used to render text.
*/
@@ -199,6 +188,18 @@ declare module 'vscode-xterm' {
* The color theme of the terminal.
*/
theme?: ITheme;
/**
* Whether "Windows mode" is enabled. Because Windows backends winpty and
* conpty operate by doing line wrapping on their side, xterm.js does not
* have access to wrapped lines. When Windows mode is enabled the following
* changes will be in effect:
*
* - Reflow is disabled.
* - Lines are assumed to be wrapped if the last character of the line is
* not whitespace.
*/
windowsMode?: boolean;
}
/**
@@ -274,7 +275,7 @@ declare module 'vscode-xterm' {
* A callback that fires when the mouse leaves a link. Note that this can
* happen even when tooltipCallback hasn't fired for the link yet.
*/
leaveCallback?: (event: MouseEvent, uri: string) => boolean | void;
leaveCallback?: () => void;
/**
* The priority of the link matcher, this defines the order in which the link
@@ -306,6 +307,14 @@ declare module 'vscode-xterm' {
dispose(): void;
}
/**
* An event that can be listened to.
* @returns an `IDisposable` to stop listening.
*/
export interface IEvent<T> {
(listener: (e: T) => any): IDisposable;
}
export interface IMarker extends IDisposable {
readonly id: number;
readonly isDisposed: boolean;
@@ -325,28 +334,39 @@ declare module 'vscode-xterm' {
/**
* The element containing the terminal.
*/
element: HTMLElement;
readonly element: HTMLElement;
/**
* The textarea that accepts input for the terminal.
*/
textarea: HTMLTextAreaElement;
readonly textarea: HTMLTextAreaElement;
/**
* The number of rows in the terminal's viewport.
* The number of rows in the terminal's viewport. Use
* `ITerminalOptions.rows` to set this in the constructor and
* `Terminal.resize` for when the terminal exists.
*/
rows: number;
readonly rows: number;
/**
* The number of columns in the terminal's viewport.
* The number of columns in the terminal's viewport. Use
* `ITerminalOptions.cols` to set this in the constructor and
* `Terminal.resize` for when the terminal exists.
*/
cols: number;
readonly cols: number;
/**
* (EXPERIMENTAL) The terminal's current buffer, this might be either the
* normal buffer or the alt buffer depending on what's running in the
* terminal.
*/
readonly buffer: IBuffer;
/**
* (EXPERIMENTAL) Get all markers registered against the buffer. If the alt
* buffer is active this will always return [].
*/
markers: IMarker[];
readonly markers: ReadonlyArray<IMarker>;
/**
* Natural language strings that can be localized.
@@ -360,6 +380,70 @@ declare module 'vscode-xterm' {
*/
constructor(options?: ITerminalOptions);
/**
* Adds an event listener for the cursor moves.
* @returns an `IDisposable` to stop listening.
*/
onCursorMove: IEvent<void>;
/**
* Adds an event listener for when a data event fires. This happens for
* example when the user types or pastes into the terminal. The event value
* is whatever `string` results, in a typical setup, this should be passed
* on to the backing pty.
* @returns an `IDisposable` to stop listening.
*/
onData: IEvent<string>;
/**
* Adds an event listener for a key is pressed. The event value contains the
* string that will be sent in the data event as well as the DOM event that
* triggered it.
* @returns an `IDisposable` to stop listening.
*/
onKey: IEvent<{ key: string, domEvent: KeyboardEvent }>;
/**
* Adds an event listener for when a line feed is added.
* @returns an `IDisposable` to stop listening.
*/
onLineFeed: IEvent<void>;
/**
* Adds an event listener for when a scroll occurs. The event value is the
* new position of the viewport.
* @returns an `IDisposable` to stop listening.
*/
onScroll: IEvent<number>;
/**
* Adds an event listener for when a selection change occurs.
* @returns an `IDisposable` to stop listening.
*/
onSelectionChange: IEvent<void>;
/**
* Adds an event listener for when rows are rendered. The event value
* contains the start row and end rows of the rendered area (ranges from `0`
* to `Terminal.rows - 1`).
* @returns an `IDisposable` to stop listening.
*/
onRender: IEvent<{ start: number, end: number }>;
/**
* Adds an event listener for when the terminal is resized. The event value
* contains the new size.
* @returns an `IDisposable` to stop listening.
*/
onResize: IEvent<{ cols: number, rows: number }>;
/**
* Adds an event listener for when an OSC 0 or OSC 2 title change occurs.
* The event value is the new title.
* @returns an `IDisposable` to stop listening.
*/
onTitleChange: IEvent<string>;
/**
* Unfocus the terminal.
*/
@@ -374,54 +458,63 @@ declare module 'vscode-xterm' {
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: 'blur' | 'focus' | 'linefeed' | 'selection', listener: () => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: 'data', listener: (...args: any[]) => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: 'key', listener: (key: string, event: KeyboardEvent) => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: 'keypress' | 'keydown', listener: (event: KeyboardEvent) => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: 'refresh', listener: (data: { start: number, end: number }) => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: 'resize', listener: (data: { cols: number, rows: number }) => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: 'scroll', listener: (ydisp: number) => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: 'title', listener: (title: string) => void): void;
/**
* Registers an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
on(type: string, listener: (...args: any[]) => void): void;
@@ -429,6 +522,7 @@ declare module 'vscode-xterm' {
* Deregisters an event listener.
* @param type The type of the event.
* @param listener The listener.
* @deprecated use `Terminal.onEvent(listener).dispose()` instead.
*/
off(type: 'blur' | 'focus' | 'linefeed' | 'selection' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void;
@@ -446,22 +540,19 @@ declare module 'vscode-xterm' {
* be used to conveniently remove the event listener.
* @param type The type of event.
* @param handler The event handler.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/
addDisposableListener(type: string, handler: (...args: any[]) => void): IDisposable;
/**
* Resizes the terminal.
* Resizes the terminal. It's best practice to debounce calls to resize,
* this will help ensure that the pty can respond to the resize event
* before another one occurs.
* @param x The number of columns to resize to.
* @param y The number of rows to resize to.
*/
resize(columns: number, rows: number): void;
/**
* Writes text to the terminal, followed by a break line character (\n).
* @param data The text to write to the terminal.
*/
writeln(data: string): void;
/**
* Opens the terminal within an element.
* @param parent The element to create the terminal within. This element
@@ -476,11 +567,35 @@ declare module 'vscode-xterm' {
* should be processed by the terminal and what keys should not.
* @param customKeyEventHandler The custom KeyboardEvent handler to attach.
* This is a function that takes a KeyboardEvent, allowing consumers to stop
* propogation and/or prevent the default action. The function returns
* propagation and/or prevent the default action. The function returns
* whether the event should be processed by xterm.js.
*/
attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void;
/**
* (EXPERIMENTAL) Adds a handler for CSI escape sequences.
* @param flag The flag should be one-character string, which specifies the
* final character (e.g "m" for SGR) of the CSI sequence.
* @param callback The function to handle the escape sequence. The callback
* is called with the numerical params, as well as the special characters
* (e.g. "$" for DECSCPP). Return true if the sequence was handled; false if
* we should try a previous handler (set by addCsiHandler or setCsiHandler).
* The most recently-added handler is tried first.
* @return An IDisposable you can call to remove this handler.
*/
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable;
/**
* (EXPERIMENTAL) Adds a handler for OSC escape sequences.
* @param ident The number (first parameter) of the sequence.
* @param callback The function to handle the escape sequence. The callback
* is called with OSC data string. Return true if the sequence was handled;
* false if we should try a previous handler (set by addOscHandler or
* setOscHandler). The most recently-added handler is tried first.
* @return An IDisposable you can call to remove this handler.
*/
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable;
/**
* (EXPERIMENTAL) Registers a link matcher, allowing custom link patterns to
* be matched and handled.
@@ -555,11 +670,24 @@ declare module 'vscode-xterm' {
*/
getSelection(): string;
/**
* Gets the selection position or undefined if there is no selection.
*/
getSelectionPosition(): ISelectionPosition | undefined;
/**
* Clears the current terminal selection.
*/
clearSelection(): void;
/**
* Selects text within the terminal.
* @param column The column the selection starts at..
* @param row The row the selection starts at.
* @param length The length of the selection.
*/
select(column: number, row: number, length: number): void;
/**
* Selects all text within the terminal.
*/
@@ -624,6 +752,20 @@ declare module 'vscode-xterm' {
*/
write(data: string): void;
/**
* Writes text to the terminal, followed by a break line character (\n).
* @param data The text to write to the terminal.
*/
writeln(data: string): void;
/**
* Writes UTF8 data to the terminal.
* This has a slight performance advantage over the string based write method
* due to lesser data conversions needed on the way from the pty to xterm.js.
* @param data The data to write to the terminal.
*/
writeUtf8(data: Uint8Array): void;
/**
* Retrieves an option's value from the terminal.
* @param key The option key.
@@ -633,7 +775,7 @@ declare module 'vscode-xterm' {
* Retrieves an option's value from the terminal.
* @param key The option key.
*/
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean;
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell' | 'windowsMode'): boolean;
/**
* Retrieves an option's value from the terminal.
* @param key The option key.
@@ -684,7 +826,7 @@ declare module 'vscode-xterm' {
* @param key The option key.
* @param value The option value.
*/
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'screenKeys' | 'useFlowControl' | 'visualBell', value: boolean): void;
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'screenKeys' | 'useFlowControl' | 'visualBell' | 'windowsMode', value: boolean): void;
/**
* Sets an option on the terminal.
* @param key The option key.
@@ -739,8 +881,134 @@ declare module 'vscode-xterm' {
* Applies an addon to the Terminal prototype, making it available to all
* newly created Terminals.
* @param addon The addon to apply.
* @deprecated Use the new loadAddon API/addon format.
*/
static applyAddon(addon: any): void;
/**
* (EXPERIMENTAL) Loads an addon into this instance of xterm.js.
* @param addon The addon to load.
*/
loadAddon(addon: ITerminalAddon): void;
}
/**
* An addon that can provide additional functionality to the terminal.
*/
export interface ITerminalAddon extends IDisposable {
/**
* (EXPERIMENTAL) This is called when the addon is activated within xterm.js.
*/
activate(terminal: Terminal): void;
}
/**
* An object representing a selecrtion within the terminal.
*/
interface ISelectionPosition {
/**
* The start column of the selection.
*/
startColumn: number;
/**
* The start row of the selection.
*/
startRow: number;
/**
* The end column of the selection.
*/
endColumn: number;
/**
* The end row of the selection.
*/
endRow: number;
}
interface IBuffer {
/**
* The y position of the cursor. This ranges between `0` (when the
* cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the
* last row).
*/
readonly cursorY: number;
/**
* The x position of the cursor. This ranges between `0` (left side) and
* `Terminal.cols - 1` (right side).
*/
readonly cursorX: number;
/**
* The line within the buffer where the top of the viewport is.
*/
readonly viewportY: number;
/**
* The line within the buffer where the top of the bottom page is (when
* fully scrolled down);
*/
readonly baseY: number;
/**
* The amount of lines in the buffer.
*/
readonly length: number;
/**
* Gets a line from the buffer, or undefined if the line index does not exist.
*
* Note that the result of this function should be used immediately after calling as when the
* terminal updates it could lead to unexpected behavior.
*
* @param y The line index to get.
*/
getLine(y: number): IBufferLine | undefined;
}
interface IBufferLine {
/**
* Whether the line is wrapped from the previous line.
*/
readonly isWrapped: boolean;
/**
* Gets a cell from the line, or undefined if the line index does not exist.
*
* Note that the result of this function should be used immediately after calling as when the
* terminal updates it could lead to unexpected behavior.
*
* @param x The character index to get.
*/
getCell(x: number): IBufferCell;
/**
* Gets the line as a string. Note that this is gets only the string for the line, not taking
* isWrapped into account.
*
* @param trimRight Whether to trim any whitespace at the right of the line.
* @param startColumn The column to start from (inclusive).
* @param endColumn The column to end at (exclusive).
*/
translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
}
interface IBufferCell {
/**
* The character within the cell.
*/
readonly char: string;
/**
* The width of the character. Some examples:
*
* - This is `1` for most cells.
* - This is `2` for wide character like CJK glyphs.
* - This is `0` for cells immediately following cells with a width of `2`.
*/
readonly width: number;
}
}
@@ -750,22 +1018,10 @@ declare module 'vscode-xterm' {
interface TerminalCore {
debug: boolean;
buffer: {
y: number;
ybase: number;
ydisp: number;
x: number;
lines: any[];
translateBufferLineToString(lineIndex: number, trimRight: boolean): string;
};
handler(text: string): void;
/**
* Emit an event on the terminal.
*/
emit(type: string, data: any): void;
_onScroll: IEventEmitter2<number>;
_onKey: IEventEmitter2<{ key: string }>;
charMeasure?: { height: number, width: number };
@@ -775,6 +1031,10 @@ declare module 'vscode-xterm' {
};
}
interface IEventEmitter2<T> {
fire(e: T): void;
}
interface ISearchOptions {
/**
* Whether the find should be done as a regex.
@@ -794,7 +1054,6 @@ declare module 'vscode-xterm' {
_core: TerminalCore;
webLinksInit(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): void;
winptyCompatInit(): void;
/**
* Find the next instance of the term, then scroll to and select it. If it
+6 -6
View File
@@ -45,13 +45,13 @@ class WindowManager {
// --- Pixel Ratio
public getPixelRatio(): number {
let ctx = document.createElement('canvas').getContext('2d');
let ctx: any = document.createElement('canvas').getContext('2d');
let dpr = window.devicePixelRatio || 1;
let bsr = (<any>ctx).webkitBackingStorePixelRatio ||
(<any>ctx).mozBackingStorePixelRatio ||
(<any>ctx).msBackingStorePixelRatio ||
(<any>ctx).oBackingStorePixelRatio ||
(<any>ctx).backingStorePixelRatio || 1;
let bsr = ctx.webkitBackingStorePixelRatio ||
ctx.mozBackingStorePixelRatio ||
ctx.msBackingStorePixelRatio ||
ctx.oBackingStorePixelRatio ||
ctx.backingStorePixelRatio || 1;
return dpr / bsr;
}
+2 -2
View File
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { IAction, IActionRunner } from 'vs/base/common/actions';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { SubmenuAction } from 'vs/base/browser/ui/menu/menu';
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
@@ -25,7 +25,7 @@ export class ContextSubMenu extends SubmenuAction {
export interface IContextMenuDelegate {
getAnchor(): HTMLElement | { x: number; y: number; width?: number; height?: number; };
getActions(): Array<IAction | ContextSubMenu>;
getActionItem?(action: IAction): IActionItem | undefined;
getActionViewItem?(action: IAction): IActionViewItem | undefined;
getActionsContext?(event?: IContextMenuEvent): any;
getKeyBinding?(action: IAction): ResolvedKeybinding | undefined;
getMenuClassName?(): string;
+3 -3
View File
@@ -329,7 +329,7 @@ function parseFormattedText(content: string): IFormatParseTree {
children: []
};
let actionItemIndex = 0;
let actionViewItemIndex = 0;
let current = root;
const stack: IFormatParseTree[] = [];
const stream = new StringStream(content);
@@ -359,8 +359,8 @@ function parseFormattedText(content: string): IFormatParseTree {
};
if (type === FormatType.Action) {
newCurrent.index = actionItemIndex;
actionItemIndex++;
newCurrent.index = actionViewItemIndex;
actionViewItemIndex++;
}
current.children!.push(newCurrent);
+59 -59
View File
@@ -18,7 +18,7 @@ import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview
import { Event, Emitter } from 'vs/base/common/event';
import { asArray } from 'vs/base/common/arrays';
export interface IActionItem {
export interface IActionViewItem {
actionRunner: IActionRunner;
setActionContext(context: any): void;
render(element: HTMLElement): void;
@@ -28,12 +28,12 @@ export interface IActionItem {
dispose(): void;
}
export interface IBaseActionItemOptions {
export interface IBaseActionViewItemOptions {
draggable?: boolean;
isMenu?: boolean;
}
export class BaseActionItem extends Disposable implements IActionItem {
export class BaseActionViewItem extends Disposable implements IActionViewItem {
element?: HTMLElement;
_context: any;
@@ -41,7 +41,7 @@ export class BaseActionItem extends Disposable implements IActionItem {
private _actionRunner: IActionRunner;
constructor(context: any, action: IAction, protected options?: IBaseActionItemOptions) {
constructor(context: any, action: IAction, protected options?: IBaseActionViewItemOptions) {
super();
this._context = context || this;
@@ -226,20 +226,20 @@ export class Separator extends Action {
}
}
export interface IActionItemOptions extends IBaseActionItemOptions {
export interface IActionViewItemOptions extends IBaseActionViewItemOptions {
icon?: boolean;
label?: boolean;
keybinding?: string | null;
}
export class ActionItem extends BaseActionItem {
export class ActionViewItem extends BaseActionViewItem {
protected label: HTMLElement;
protected options: IActionItemOptions;
protected options: IActionViewItemOptions;
private cssClass?: string;
constructor(context: any, action: IAction, options: IActionItemOptions = {}) {
constructor(context: any, action: IAction, options: IActionViewItemOptions = {}) {
super(context, action, options);
this.options = options;
@@ -363,14 +363,14 @@ export interface ActionTrigger {
keyDown: boolean;
}
export interface IActionItemProvider {
(action: IAction): IActionItem | undefined;
export interface IActionViewItemProvider {
(action: IAction): IActionViewItem | undefined;
}
export interface IActionBarOptions {
orientation?: ActionsOrientation;
context?: any;
actionItemProvider?: IActionItemProvider;
actionViewItemProvider?: IActionViewItemProvider;
actionRunner?: IActionRunner;
ariaLabel?: string;
animated?: boolean;
@@ -386,7 +386,7 @@ const defaultOptions: IActionBarOptions = {
}
};
export interface IActionOptions extends IActionItemOptions {
export interface IActionOptions extends IActionViewItemOptions {
index?: number;
}
@@ -397,8 +397,8 @@ export class ActionBar extends Disposable implements IActionRunner {
private _actionRunner: IActionRunner;
private _context: any;
// Items
items: IActionItem[];
// View Items
viewItems: IActionViewItem[];
protected focusedItem?: number;
private focusTracker: DOM.IFocusTracker;
@@ -438,7 +438,7 @@ export class ActionBar extends Disposable implements IActionRunner {
this._register(this._actionRunner.onDidRun(e => this._onDidRun.fire(e)));
this._register(this._actionRunner.onDidBeforeRun(e => this._onDidBeforeRun.fire(e)));
this.items = [];
this.viewItems = [];
this.focusedItem = undefined;
this.domNode = document.createElement('div');
@@ -575,7 +575,7 @@ export class ActionBar extends Disposable implements IActionRunner {
set context(context: any) {
this._context = context;
this.items.forEach(i => i.setActionContext(context));
this.viewItems.forEach(i => i.setActionContext(context));
}
get actionRunner(): IActionRunner {
@@ -585,7 +585,7 @@ export class ActionBar extends Disposable implements IActionRunner {
set actionRunner(actionRunner: IActionRunner) {
if (actionRunner) {
this._actionRunner = actionRunner;
this.items.forEach(item => item.actionRunner = actionRunner);
this.viewItems.forEach(item => item.actionRunner = actionRunner);
}
}
@@ -599,36 +599,36 @@ export class ActionBar extends Disposable implements IActionRunner {
let index = types.isNumber(options.index) ? options.index : null;
actions.forEach((action: IAction) => {
const actionItemElement = document.createElement('li');
actionItemElement.className = 'action-item';
actionItemElement.setAttribute('role', 'presentation');
const actionViewItemElement = document.createElement('li');
actionViewItemElement.className = 'action-item';
actionViewItemElement.setAttribute('role', 'presentation');
// Prevent native context menu on actions
this._register(DOM.addDisposableListener(actionItemElement, DOM.EventType.CONTEXT_MENU, (e: DOM.EventLike) => {
this._register(DOM.addDisposableListener(actionViewItemElement, DOM.EventType.CONTEXT_MENU, (e: DOM.EventLike) => {
e.preventDefault();
e.stopPropagation();
}));
let item: IActionItem | undefined;
let item: IActionViewItem | undefined;
if (this.options.actionItemProvider) {
item = this.options.actionItemProvider(action);
if (this.options.actionViewItemProvider) {
item = this.options.actionViewItemProvider(action);
}
if (!item) {
item = new ActionItem(this.context, action, options);
item = new ActionViewItem(this.context, action, options);
}
item.actionRunner = this._actionRunner;
item.setActionContext(this.context);
item.render(actionItemElement);
item.render(actionViewItemElement);
if (index === null || index < 0 || index >= this.actionsList.children.length) {
this.actionsList.appendChild(actionItemElement);
this.items.push(item);
this.actionsList.appendChild(actionViewItemElement);
this.viewItems.push(item);
} else {
this.actionsList.insertBefore(actionItemElement, this.actionsList.children[index]);
this.items.splice(index, 0, item);
this.actionsList.insertBefore(actionViewItemElement, this.actionsList.children[index]);
this.viewItems.splice(index, 0, item);
index++;
}
});
@@ -657,23 +657,23 @@ export class ActionBar extends Disposable implements IActionRunner {
}
pull(index: number): void {
if (index >= 0 && index < this.items.length) {
if (index >= 0 && index < this.viewItems.length) {
this.actionsList.removeChild(this.actionsList.childNodes[index]);
dispose(this.items.splice(index, 1));
dispose(this.viewItems.splice(index, 1));
}
}
clear(): void {
this.items = dispose(this.items);
this.viewItems = dispose(this.viewItems);
DOM.clearNode(this.actionsList);
}
length(): number {
return this.items.length;
return this.viewItems.length;
}
isEmpty(): boolean {
return this.items.length === 0;
return this.viewItems.length === 0;
}
focus(index?: number): void;
@@ -691,7 +691,7 @@ export class ActionBar extends Disposable implements IActionRunner {
if (selectFirst && typeof this.focusedItem === 'undefined') {
// Focus the first enabled item
this.focusedItem = this.items.length - 1;
this.focusedItem = this.viewItems.length - 1;
this.focusNext();
} else {
if (index !== undefined) {
@@ -704,15 +704,15 @@ export class ActionBar extends Disposable implements IActionRunner {
protected focusNext(): void {
if (typeof this.focusedItem === 'undefined') {
this.focusedItem = this.items.length - 1;
this.focusedItem = this.viewItems.length - 1;
}
const startIndex = this.focusedItem;
let item: IActionItem;
let item: IActionViewItem;
do {
this.focusedItem = (this.focusedItem + 1) % this.items.length;
item = this.items[this.focusedItem];
this.focusedItem = (this.focusedItem + 1) % this.viewItems.length;
item = this.viewItems[this.focusedItem];
} while (this.focusedItem !== startIndex && !item.isEnabled());
if (this.focusedItem === startIndex && !item.isEnabled()) {
@@ -728,16 +728,16 @@ export class ActionBar extends Disposable implements IActionRunner {
}
const startIndex = this.focusedItem;
let item: IActionItem;
let item: IActionViewItem;
do {
this.focusedItem = this.focusedItem - 1;
if (this.focusedItem < 0) {
this.focusedItem = this.items.length - 1;
this.focusedItem = this.viewItems.length - 1;
}
item = this.items[this.focusedItem];
item = this.viewItems[this.focusedItem];
} while (this.focusedItem !== startIndex && !item.isEnabled());
if (this.focusedItem === startIndex && !item.isEnabled()) {
@@ -752,21 +752,21 @@ export class ActionBar extends Disposable implements IActionRunner {
this.actionsList.focus();
}
for (let i = 0; i < this.items.length; i++) {
const item = this.items[i];
const actionItem = item;
for (let i = 0; i < this.viewItems.length; i++) {
const item = this.viewItems[i];
const actionViewItem = item;
if (i === this.focusedItem) {
if (types.isFunction(actionItem.isEnabled)) {
if (actionItem.isEnabled() && types.isFunction(actionItem.focus)) {
actionItem.focus(fromRight);
if (types.isFunction(actionViewItem.isEnabled)) {
if (actionViewItem.isEnabled() && types.isFunction(actionViewItem.focus)) {
actionViewItem.focus(fromRight);
} else {
this.actionsList.focus();
}
}
} else {
if (types.isFunction(actionItem.blur)) {
actionItem.blur();
if (types.isFunction(actionViewItem.blur)) {
actionViewItem.blur();
}
}
}
@@ -778,16 +778,16 @@ export class ActionBar extends Disposable implements IActionRunner {
}
// trigger action
const actionItem = this.items[this.focusedItem];
if (actionItem instanceof BaseActionItem) {
const context = (actionItem._context === null || actionItem._context === undefined) ? event : actionItem._context;
this.run(actionItem._action, context);
const actionViewItem = this.viewItems[this.focusedItem];
if (actionViewItem instanceof BaseActionViewItem) {
const context = (actionViewItem._context === null || actionViewItem._context === undefined) ? event : actionViewItem._context;
this.run(actionViewItem._action, context);
}
}
private cancel(): void {
if (document.activeElement instanceof HTMLElement) {
(<HTMLElement>document.activeElement).blur(); // remove focus from focused action
document.activeElement.blur(); // remove focus from focused action
}
this._onDidCancel.fire();
@@ -798,8 +798,8 @@ export class ActionBar extends Disposable implements IActionRunner {
}
dispose(): void {
dispose(this.items);
this.items = [];
dispose(this.viewItems);
this.viewItems = [];
DOM.removeNode(this.getContainer());
@@ -807,7 +807,7 @@ export class ActionBar extends Disposable implements IActionRunner {
}
}
export class SelectActionItem extends BaseActionItem {
export class SelectActionViewItem extends BaseActionViewItem {
protected selectBox: SelectBox;
constructor(ctx: any, action: IAction, options: ISelectOptionItem[], selected: number, contextViewProvider: IContextViewProvider, selectBoxOptions?: ISelectBoxOptions) {
+2 -2
View File
@@ -11,7 +11,7 @@ import { Color } from 'vs/base/common/color';
import { Emitter, Event } from 'vs/base/common/event';
import { KeyCode } from 'vs/base/common/keyCodes';
import * as objects from 'vs/base/common/objects';
import { BaseActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
export interface ICheckboxOpts extends ICheckboxStyles {
@@ -28,7 +28,7 @@ const defaultOpts = {
inputActiveOptionBorder: Color.fromHex('#007ACC')
};
export class CheckboxActionItem extends BaseActionItem {
export class CheckboxActionViewItem extends BaseActionViewItem {
private checkbox: Checkbox;
private disposables: IDisposable[] = [];
@@ -132,13 +132,13 @@ export class ContextView extends Disposable {
ContextView.BUBBLE_UP_EVENTS.forEach(event => {
toDisposeOnSetContainer.push(DOM.addStandardDisposableListener(this.container!, event, (e: Event) => {
this.onDOMEvent(e, <HTMLElement>document.activeElement, false);
this.onDOMEvent(e, false);
}));
});
ContextView.BUBBLE_DOWN_EVENTS.forEach(event => {
toDisposeOnSetContainer.push(DOM.addStandardDisposableListener(this.container!, event, (e: Event) => {
this.onDOMEvent(e, <HTMLElement>document.activeElement, true);
this.onDOMEvent(e, true);
}, true));
});
@@ -213,13 +213,11 @@ export class ContextView extends Disposable {
height: elementPosition.height
};
} else {
let realAnchor = <IAnchor>anchor;
around = {
top: realAnchor.y,
left: realAnchor.x,
width: realAnchor.width || 1,
height: realAnchor.height || 2
top: anchor.y,
left: anchor.x,
width: anchor.width || 1,
height: anchor.height || 2
};
}
@@ -278,7 +276,7 @@ export class ContextView extends Disposable {
return !!this.delegate;
}
private onDOMEvent(e: Event, element: HTMLElement, onCapture: boolean): void {
private onDOMEvent(e: Event, onCapture: boolean): void {
if (this.delegate) {
if (this.delegate.onDOMEvent) {
this.delegate.onDOMEvent(e, <HTMLElement>document.activeElement);
+9 -9
View File
@@ -6,7 +6,7 @@
import 'vs/css!./dropdown';
import { Gesture, EventType as GestureEventType } from 'vs/base/browser/touch';
import { ActionRunner, IAction, IActionRunner } from 'vs/base/common/actions';
import { BaseActionItem, IActionItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { BaseActionViewItem, IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IContextViewProvider, IAnchor, AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
import { IMenuOptions } from 'vs/base/browser/ui/menu/menu';
@@ -247,7 +247,7 @@ export class DropdownMenu extends BaseDropdown {
getAnchor: () => this.element,
getActions: () => this.actions,
getActionsContext: () => this.menuOptions ? this.menuOptions.context : null,
getActionItem: action => this.menuOptions && this.menuOptions.actionItemProvider ? this.menuOptions.actionItemProvider(action) : undefined,
getActionViewItem: action => this.menuOptions && this.menuOptions.actionViewItemProvider ? this.menuOptions.actionViewItemProvider(action) : undefined,
getKeyBinding: action => this.menuOptions && this.menuOptions.getKeyBinding ? this.menuOptions.getKeyBinding(action) : undefined,
getMenuClassName: () => this.menuClassName,
onHide: () => this.onHide(),
@@ -266,23 +266,23 @@ export class DropdownMenu extends BaseDropdown {
}
}
export class DropdownMenuActionItem extends BaseActionItem {
export class DropdownMenuActionViewItem extends BaseActionViewItem {
private menuActionsOrProvider: any;
private dropdownMenu: DropdownMenu;
private contextMenuProvider: IContextMenuProvider;
private actionItemProvider?: IActionItemProvider;
private actionViewItemProvider?: IActionViewItemProvider;
private keybindings?: (action: IAction) => ResolvedKeybinding | undefined;
private clazz: string | undefined;
private anchorAlignmentProvider: (() => AnchorAlignment) | undefined;
constructor(action: IAction, menuActions: IAction[], contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
constructor(action: IAction, menuActionsOrProvider: any, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment) {
constructor(action: IAction, menuActions: IAction[], contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
constructor(action: IAction, menuActionsOrProvider: any, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment) {
super(null, action);
this.menuActionsOrProvider = menuActionsOrProvider;
this.contextMenuProvider = contextMenuProvider;
this.actionItemProvider = actionItemProvider;
this.actionViewItemProvider = actionViewItemProvider;
this.actionRunner = actionRunner;
this.keybindings = keybindings;
this.clazz = clazz;
@@ -319,7 +319,7 @@ export class DropdownMenuActionItem extends BaseActionItem {
this.dropdownMenu = this._register(new DropdownMenu(container, options));
this.dropdownMenu.menuOptions = {
actionItemProvider: this.actionItemProvider,
actionViewItemProvider: this.actionViewItemProvider,
actionRunner: this.actionRunner,
getKeyBinding: this.keybindings,
context: this._context
+1 -1
View File
@@ -161,7 +161,7 @@ export class InputBox extends Widget {
let tagName = this.options.flexibleHeight ? 'textarea' : 'input';
let wrapper = dom.append(this.element, $('.wrapper'));
this.input = <HTMLInputElement>dom.append(wrapper, $(tagName + '.input'));
this.input = dom.append(wrapper, $(tagName + '.input'));
this.input.setAttribute('autocorrect', 'off');
this.input.setAttribute('autocapitalize', 'off');
this.input.setAttribute('spellcheck', 'false');
+37 -37
View File
@@ -7,7 +7,7 @@ import 'vs/css!./menu';
import * as nls from 'vs/nls';
import * as strings from 'vs/base/common/strings';
import { IActionRunner, IAction, Action } from 'vs/base/common/actions';
import { ActionBar, IActionItemProvider, ActionsOrientation, Separator, ActionItem, IActionItemOptions, BaseActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { ActionBar, IActionViewItemProvider, ActionsOrientation, Separator, ActionViewItem, IActionViewItemOptions, BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { ResolvedKeybinding, KeyCode } from 'vs/base/common/keyCodes';
import { addClass, EventType, EventHelper, EventLike, removeTabIndexAndUpdateFocus, isAncestor, hasClass, addDisposableListener, removeClass, append, $, addClasses, removeClasses } from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
@@ -39,7 +39,7 @@ export const MENU_ESCAPED_MNEMONIC_REGEX: RegExp = createMenuEscapedMnemonicRegE
export interface IMenuOptions {
context?: any;
actionItemProvider?: IActionItemProvider;
actionViewItemProvider?: IActionViewItemProvider;
actionRunner?: IActionRunner;
getKeyBinding?: (action: IAction) => ResolvedKeybinding | undefined;
ariaLabel?: string;
@@ -70,7 +70,7 @@ interface ISubMenuData {
}
export class Menu extends ActionBar {
private mnemonics: Map<string, Array<MenuActionItem>>;
private mnemonics: Map<string, Array<BaseMenuActionViewItem>>;
private menuDisposables: IDisposable[];
private scrollableElement: DomScrollableElement;
private menuElement: HTMLElement;
@@ -88,7 +88,7 @@ export class Menu extends ActionBar {
super(menuElement, {
orientation: ActionsOrientation.VERTICAL,
actionItemProvider: action => this.doGetActionItem(action, options, parentData),
actionViewItemProvider: action => this.doGetActionViewItem(action, options, parentData),
context: options.context,
actionRunner: options.actionRunner,
ariaLabel: options.ariaLabel,
@@ -113,7 +113,7 @@ export class Menu extends ActionBar {
const actions = this.mnemonics.get(key)!;
if (actions.length === 1) {
if (actions[0] instanceof SubmenuActionItem) {
if (actions[0] instanceof SubmenuMenuActionViewItem) {
this.focusItemByElement(actions[0].container);
}
@@ -138,7 +138,7 @@ export class Menu extends ActionBar {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Home) || event.equals(KeyCode.PageUp)) {
this.focusedItem = this.items.length - 1;
this.focusedItem = this.viewItems.length - 1;
this.focusNext();
EventHelper.stop(e, true);
} else if (event.equals(KeyCode.End) || event.equals(KeyCode.PageDown)) {
@@ -189,7 +189,7 @@ export class Menu extends ActionBar {
parent: this
};
this.mnemonics = new Map<string, Array<MenuActionItem>>();
this.mnemonics = new Map<string, Array<BaseMenuActionViewItem>>();
this.push(actions, { icon: true, label: true, isMenu: true });
@@ -223,7 +223,7 @@ export class Menu extends ActionBar {
container.appendChild(this.scrollableElement.getDomNode());
this.scrollableElement.scanDomNode();
this.items.filter(item => !(item instanceof MenuSeparatorActionItem)).forEach((item: MenuActionItem, index: number, array: any[]) => {
this.viewItems.filter(item => !(item instanceof MenuSeparatorActionViewItem)).forEach((item: BaseMenuActionViewItem, index: number, array: any[]) => {
item.updatePositionInSet(index + 1, array.length);
});
}
@@ -241,9 +241,9 @@ export class Menu extends ActionBar {
this.domNode.style.backgroundColor = bgColor;
container.style.boxShadow = shadow;
if (this.items) {
this.items.forEach(item => {
if (item instanceof MenuActionItem || item instanceof MenuSeparatorActionItem) {
if (this.viewItems) {
this.viewItems.forEach(item => {
if (item instanceof BaseMenuActionViewItem || item instanceof MenuSeparatorActionViewItem) {
item.style(style);
}
});
@@ -263,12 +263,12 @@ export class Menu extends ActionBar {
}
trigger(index: number): void {
if (index <= this.items.length && index >= 0) {
const item = this.items[index];
if (item instanceof SubmenuActionItem) {
if (index <= this.viewItems.length && index >= 0) {
const item = this.viewItems[index];
if (item instanceof SubmenuMenuActionViewItem) {
super.focus(index);
item.open(true);
} else if (item instanceof MenuActionItem) {
} else if (item instanceof BaseMenuActionViewItem) {
super.run(item._action, item._context);
} else {
return;
@@ -295,27 +295,27 @@ export class Menu extends ActionBar {
}
}
private doGetActionItem(action: IAction, options: IMenuOptions, parentData: ISubMenuData): BaseActionItem {
private doGetActionViewItem(action: IAction, options: IMenuOptions, parentData: ISubMenuData): BaseActionViewItem {
if (action instanceof Separator) {
return new MenuSeparatorActionItem(options.context, action, { icon: true });
return new MenuSeparatorActionViewItem(options.context, action, { icon: true });
} else if (action instanceof SubmenuAction) {
const menuActionItem = new SubmenuActionItem(action, action.entries, parentData, options);
const menuActionViewItem = new SubmenuMenuActionViewItem(action, action.entries, parentData, options);
if (options.enableMnemonics) {
const mnemonic = menuActionItem.getMnemonic();
if (mnemonic && menuActionItem.isEnabled()) {
let actionItems: MenuActionItem[] = [];
const mnemonic = menuActionViewItem.getMnemonic();
if (mnemonic && menuActionViewItem.isEnabled()) {
let actionViewItems: BaseMenuActionViewItem[] = [];
if (this.mnemonics.has(mnemonic)) {
actionItems = this.mnemonics.get(mnemonic)!;
actionViewItems = this.mnemonics.get(mnemonic)!;
}
actionItems.push(menuActionItem);
actionViewItems.push(menuActionViewItem);
this.mnemonics.set(mnemonic, actionItems);
this.mnemonics.set(mnemonic, actionViewItems);
}
}
return menuActionItem;
return menuActionViewItem;
} else {
const menuItemOptions: IMenuItemOptions = { enableMnemonics: options.enableMnemonics };
if (options.getKeyBinding) {
@@ -329,32 +329,32 @@ export class Menu extends ActionBar {
}
}
const menuActionItem = new MenuActionItem(options.context, action, menuItemOptions);
const menuActionViewItem = new BaseMenuActionViewItem(options.context, action, menuItemOptions);
if (options.enableMnemonics) {
const mnemonic = menuActionItem.getMnemonic();
if (mnemonic && menuActionItem.isEnabled()) {
let actionItems: MenuActionItem[] = [];
const mnemonic = menuActionViewItem.getMnemonic();
if (mnemonic && menuActionViewItem.isEnabled()) {
let actionViewItems: BaseMenuActionViewItem[] = [];
if (this.mnemonics.has(mnemonic)) {
actionItems = this.mnemonics.get(mnemonic)!;
actionViewItems = this.mnemonics.get(mnemonic)!;
}
actionItems.push(menuActionItem);
actionViewItems.push(menuActionViewItem);
this.mnemonics.set(mnemonic, actionItems);
this.mnemonics.set(mnemonic, actionViewItems);
}
}
return menuActionItem;
return menuActionViewItem;
}
}
}
interface IMenuItemOptions extends IActionItemOptions {
interface IMenuItemOptions extends IActionViewItemOptions {
enableMnemonics?: boolean;
}
class MenuActionItem extends BaseActionItem {
class BaseMenuActionViewItem extends BaseActionViewItem {
public container: HTMLElement;
@@ -562,7 +562,7 @@ class MenuActionItem extends BaseActionItem {
}
}
class SubmenuActionItem extends MenuActionItem {
class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
private mysubmenu: Menu | null;
private submenuContainer: HTMLElement | undefined;
private submenuIndicator: HTMLElement;
@@ -778,7 +778,7 @@ class SubmenuActionItem extends MenuActionItem {
}
}
class MenuSeparatorActionItem extends ActionItem {
class MenuSeparatorActionViewItem extends ActionViewItem {
style(style: IMenuStyles): void {
this.label.style.borderBottomColor = style.separatorColor ? `${style.separatorColor}` : null;
}
@@ -41,8 +41,8 @@ class SelectListRenderer implements IListRenderer<ISelectOptionItem, ISelectList
constructor() { }
renderTemplate(container: HTMLElement): any {
const data = <ISelectListTemplateData>Object.create(null);
renderTemplate(container: HTMLElement): ISelectListTemplateData {
const data: ISelectListTemplateData = Object.create(null);
data.disposables = [];
data.root = container;
data.text = dom.append(container, $('.option-text'));
@@ -54,10 +54,10 @@ class SelectListRenderer implements IListRenderer<ISelectOptionItem, ISelectList
}
renderElement(element: ISelectOptionItem, index: number, templateData: ISelectListTemplateData): void {
const data = <ISelectListTemplateData>templateData;
const text = (<ISelectOptionItem>element).text;
const decoratorRight = (<ISelectOptionItem>element).decoratorRight;
const isDisabled = (<ISelectOptionItem>element).isDisabled;
const data: ISelectListTemplateData = templateData;
const text = element.text;
const decoratorRight = element.decoratorRight;
const isDisabled = element.isDisabled;
data.text.textContent = text;
data.decoratorRight.innerText = (!!decoratorRight ? decoratorRight : '');
@@ -73,10 +73,10 @@ class SelectListRenderer implements IListRenderer<ISelectOptionItem, ISelectList
// pseudo-select disabled option
if (isDisabled) {
dom.addClass((<HTMLElement>data.root), 'option-disabled');
dom.addClass(data.root, 'option-disabled');
} else {
// Make sure we do class removal from prior template rendering
dom.removeClass((<HTMLElement>data.root), 'option-disabled');
dom.removeClass(data.root, 'option-disabled');
}
}
@@ -836,9 +836,9 @@ export class SelectBoxList implements ISelectBoxDelegate, IListVirtualDelegate<I
private renderDescriptionMarkdown(text: string): HTMLElement {
const cleanRenderedMarkdown = (element: Node) => {
for (let i = 0; i < element.childNodes.length; i++) {
const child = element.childNodes.item(i);
const child = <Element>element.childNodes.item(i);
const tagName = (<Element>child).tagName && (<Element>child).tagName.toLowerCase();
const tagName = child.tagName && child.tagName.toLowerCase();
if (tagName === 'img') {
element.removeChild(child);
} else {
@@ -234,8 +234,8 @@ export class SplitView extends Disposable {
});
const sashEventMapper = this.orientation === Orientation.VERTICAL
? (e: IBaseSashEvent) => ({ sash, start: e.startY, current: e.currentY, alt: e.altKey } as ISashEvent)
: (e: IBaseSashEvent) => ({ sash, start: e.startX, current: e.currentX, alt: e.altKey } as ISashEvent);
? (e: IBaseSashEvent) => ({ sash, start: e.startY, current: e.currentY, alt: e.altKey })
: (e: IBaseSashEvent) => ({ sash, start: e.startX, current: e.currentX, alt: e.altKey });
const onStart = Event.map(sash.onDidStart, sashEventMapper);
const onStartDisposable = onStart(this.onSashStart, this);
+18 -18
View File
@@ -6,8 +6,8 @@
import 'vs/css!./toolbar';
import * as nls from 'vs/nls';
import { Action, IActionRunner, IAction } from 'vs/base/common/actions';
import { ActionBar, ActionsOrientation, IActionItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { IContextMenuProvider, DropdownMenuActionItem } from 'vs/base/browser/ui/dropdown/dropdown';
import { ActionBar, ActionsOrientation, IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { IContextMenuProvider, DropdownMenuActionViewItem } from 'vs/base/browser/ui/dropdown/dropdown';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { Disposable } from 'vs/base/common/lifecycle';
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
@@ -17,7 +17,7 @@ export const CONTEXT = 'context.toolbar';
export interface IToolBarOptions {
orientation?: ActionsOrientation;
actionItemProvider?: IActionItemProvider;
actionViewItemProvider?: IActionViewItemProvider;
ariaLabel?: string;
getKeyBinding?: (action: IAction) => ResolvedKeybinding | undefined;
actionRunner?: IActionRunner;
@@ -32,7 +32,7 @@ export class ToolBar extends Disposable {
private options: IToolBarOptions;
private actionBar: ActionBar;
private toggleMenuAction: ToggleMenuAction;
private toggleMenuActionItem?: DropdownMenuActionItem;
private toggleMenuActionViewItem?: DropdownMenuActionViewItem;
private hasSecondaryActions: boolean;
private lookupKeybindings: boolean;
@@ -42,7 +42,7 @@ export class ToolBar extends Disposable {
this.options = options;
this.lookupKeybindings = typeof this.options.getKeyBinding === 'function';
this.toggleMenuAction = this._register(new ToggleMenuAction(() => this.toggleMenuActionItem && this.toggleMenuActionItem.show(), options.toggleMenuTitle));
this.toggleMenuAction = this._register(new ToggleMenuAction(() => this.toggleMenuActionViewItem && this.toggleMenuActionViewItem.show(), options.toggleMenuTitle));
let element = document.createElement('div');
element.className = 'monaco-toolbar';
@@ -52,33 +52,33 @@ export class ToolBar extends Disposable {
orientation: options.orientation,
ariaLabel: options.ariaLabel,
actionRunner: options.actionRunner,
actionItemProvider: (action: Action) => {
actionViewItemProvider: (action: Action) => {
// Return special action item for the toggle menu action
if (action.id === ToggleMenuAction.ID) {
// Dispose old
if (this.toggleMenuActionItem) {
this.toggleMenuActionItem.dispose();
if (this.toggleMenuActionViewItem) {
this.toggleMenuActionViewItem.dispose();
}
// Create new
this.toggleMenuActionItem = new DropdownMenuActionItem(
this.toggleMenuActionViewItem = new DropdownMenuActionViewItem(
action,
(<ToggleMenuAction>action).menuActions,
contextMenuProvider,
this.options.actionItemProvider,
this.options.actionViewItemProvider,
this.actionRunner,
this.options.getKeyBinding,
'toolbar-toggle-more',
this.options.anchorAlignmentProvider
);
this.toggleMenuActionItem!.setActionContext(this.actionBar.context);
this.toggleMenuActionViewItem!.setActionContext(this.actionBar.context);
return this.toggleMenuActionItem;
return this.toggleMenuActionViewItem;
}
return options.actionItemProvider ? options.actionItemProvider(action) : undefined;
return options.actionViewItemProvider ? options.actionViewItemProvider(action) : undefined;
}
}));
}
@@ -93,8 +93,8 @@ export class ToolBar extends Disposable {
set context(context: any) {
this.actionBar.context = context;
if (this.toggleMenuActionItem) {
this.toggleMenuActionItem.setActionContext(context);
if (this.toggleMenuActionViewItem) {
this.toggleMenuActionViewItem.setActionContext(context);
}
}
@@ -156,9 +156,9 @@ export class ToolBar extends Disposable {
}
dispose(): void {
if (this.toggleMenuActionItem) {
this.toggleMenuActionItem.dispose();
this.toggleMenuActionItem = undefined;
if (this.toggleMenuActionViewItem) {
this.toggleMenuActionViewItem.dispose();
this.toggleMenuActionViewItem = undefined;
}
super.dispose();
+1 -1
View File
@@ -29,7 +29,7 @@ export interface IActionRunner extends IDisposable {
onDidBeforeRun: Event<IRunEvent>;
}
export interface IActionItem {
export interface IActionViewItem {
actionRunner: IActionRunner;
setActionContext(context: any): void;
render(element: any /* HTMLElement */): void;
+1 -1
View File
@@ -79,7 +79,7 @@ export function getFirstFrame(arg0: IRemoteConsoleLog | string | undefined): ISt
uri: URI.file(matches[1]),
line: Number(matches[2]),
column: Number(matches[3])
} as IStackFrame;
};
}
}
+11 -8
View File
@@ -139,19 +139,22 @@ export function isUNC(path: string): boolean {
}
// Reference: https://en.wikipedia.org/wiki/Filename
const INVALID_FILE_CHARS = isWindows ? /[\\/:\*\?"<>\|]/g : /[\\/]/g;
const WINDOWS_INVALID_FILE_CHARS = /[\\/:\*\?"<>\|]/g;
const UNIX_INVALID_FILE_CHARS = /[\\/]/g;
const WINDOWS_FORBIDDEN_NAMES = /^(con|prn|aux|clock\$|nul|lpt[0-9]|com[0-9])$/i;
export function isValidBasename(name: string | null | undefined): boolean {
export function isValidBasename(name: string | null | undefined, isWindowsOS: boolean = isWindows): boolean {
const invalidFileChars = isWindowsOS ? WINDOWS_INVALID_FILE_CHARS : UNIX_INVALID_FILE_CHARS;
if (!name || name.length === 0 || /^\s+$/.test(name)) {
return false; // require a name that is not just whitespace
}
INVALID_FILE_CHARS.lastIndex = 0; // the holy grail of software development
if (INVALID_FILE_CHARS.test(name)) {
invalidFileChars.lastIndex = 0; // the holy grail of software development
if (invalidFileChars.test(name)) {
return false; // check for certain invalid file characters
}
if (isWindows && WINDOWS_FORBIDDEN_NAMES.test(name)) {
if (isWindowsOS && WINDOWS_FORBIDDEN_NAMES.test(name)) {
return false; // check for certain invalid file names
}
@@ -159,16 +162,16 @@ export function isValidBasename(name: string | null | undefined): boolean {
return false; // check for reserved values
}
if (isWindows && name[name.length - 1] === '.') {
if (isWindowsOS && name[name.length - 1] === '.') {
return false; // Windows: file cannot end with a "."
}
if (isWindows && name.length !== name.trim().length) {
if (isWindowsOS && name.length !== name.trim().length) {
return false; // Windows: file cannot end with a whitespace
}
if (name.length > 255) {
return false; // most file systems do not allow files > 255 lenth
return false; // most file systems do not allow files > 255 length
}
return true;
+8 -3
View File
@@ -197,7 +197,11 @@ function guessMimeTypeByFirstline(firstLine: string): string | null {
}
if (firstLine.length > 0) {
for (const association of registeredAssociations) {
// We want to prioritize associations based on the order they are registered so that the last registered
// association wins over all other. This is for https://github.com/Microsoft/vscode/issues/20074
for (let i = registeredAssociations.length - 1; i >= 0; i--) {
const association = registeredAssociations[i];
if (!association.firstline) {
continue;
}
@@ -230,10 +234,11 @@ export function isUnspecific(mime: string[] | string): boolean {
* 2. Otherwise, if there are other extensions, suggest the first one.
* 3. Otherwise, suggest the prefix.
*/
export function suggestFilename(langId: string | null, prefix: string): string {
export function suggestFilename(mode: string | undefined, prefix: string): string {
const extensions = registeredAssociations
.filter(assoc => !assoc.userConfigured && assoc.extension && assoc.id === langId)
.filter(assoc => !assoc.userConfigured && assoc.extension && assoc.id === mode)
.map(assoc => assoc.extension);
const extensionsWithDotFirst = coalesce(extensions)
.filter(assoc => startsWith(assoc, '.'));
+1 -1
View File
@@ -14,7 +14,7 @@ export function deepClone<T>(obj: T): T {
return obj as any;
}
const result: any = Array.isArray(obj) ? [] : {};
Object.keys(obj).forEach((key: string) => {
Object.keys(obj as any).forEach((key: string) => {
if (obj[key] && typeof obj[key] === 'object') {
result[key] = deepClone(obj[key]);
} else {
+1 -1
View File
@@ -79,7 +79,7 @@ export abstract class Parser {
this._problemReporter.fatal(message);
}
protected static merge<T>(destination: T, source: T, overwrite: boolean): void {
protected static merge<T extends object>(destination: T, source: T, overwrite: boolean): void {
Object.keys(source).forEach((key: string) => {
const destValue = destination[key];
const sourceValue = source[key];
+24 -6
View File
@@ -176,28 +176,46 @@ export function isAbsolutePath(resource: URI): boolean {
/**
* Returns true if the URI path has a trailing path separator
*/
export function hasTrailingPathSeparator(resource: URI): boolean {
export function hasTrailingPathSeparator(resource: URI, sep: string = paths.sep): boolean {
if (resource.scheme === Schemas.file) {
const fsp = originalFSPath(resource);
return fsp.length > extpath.getRoot(fsp).length && fsp[fsp.length - 1] === paths.sep;
return fsp.length > extpath.getRoot(fsp).length && fsp[fsp.length - 1] === sep;
} else {
const p = resource.path;
return p.length > 1 && p.charCodeAt(p.length - 1) === CharCode.Slash; // ignore the slash at offset 0
}
}
/**
* Removes a trailing path seperator, if theres one.
* Removes a trailing path separator, if there's one.
* Important: Doesn't remove the first slash, it would make the URI invalid
*/
export function removeTrailingPathSeparator(resource: URI): URI {
if (hasTrailingPathSeparator(resource)) {
export function removeTrailingPathSeparator(resource: URI, sep: string = paths.sep): URI {
if (hasTrailingPathSeparator(resource, sep)) {
return resource.with({ path: resource.path.substr(0, resource.path.length - 1) });
}
return resource;
}
/**
* Adds a trailing path separator to the URI if there isn't one already.
* For example, c:\ would be unchanged, but c:\users would become c:\users\
*/
export function addTrailingPathSeparator(resource: URI, sep: string = paths.sep): URI {
let isRootSep: boolean = false;
if (resource.scheme === Schemas.file) {
const fsp = originalFSPath(resource);
isRootSep = ((fsp !== undefined) && (fsp.length === extpath.getRoot(fsp).length) && (fsp[fsp.length - 1] === sep));
} else {
sep = '/';
const p = resource.path;
isRootSep = p.length === 1 && p.charCodeAt(p.length - 1) === CharCode.Slash;
}
if (!isRootSep && !hasTrailingPathSeparator(resource, sep)) {
return resource.with({ path: resource.path + '/' });
}
return resource;
}
/**
* Returns a relative path between two URIs. If the URIs don't have the same schema or authority, `undefined` is returned.
+1 -1
View File
@@ -233,7 +233,7 @@ export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean {
// We check against an empty string. If the regular expression doesn't advance
// (e.g. ends in an endless loop) it will match an empty string.
const match = regexp.exec('');
return !!(match && <any>regexp.lastIndex === 0);
return !!(match && regexp.lastIndex === 0);
}
export function regExpContainsBackreference(regexpValue: string): boolean {
+12 -1
View File
@@ -670,4 +670,15 @@ export async function mkdirp(path: string, mode?: number, token?: CancellationTo
// Any other error
return Promise.reject(error);
}
}
}
// See https://github.com/Microsoft/vscode/issues/30180
const WIN32_MAX_FILE_SIZE = 300 * 1024 * 1024; // 300 MB
const GENERAL_MAX_FILE_SIZE = 16 * 1024 * 1024 * 1024; // 16 GB
// See https://github.com/v8/v8/blob/5918a23a3d571b9625e5cce246bdd5b46ff7cd8b/src/heap/heap.cc#L149
const WIN32_MAX_HEAP_SIZE = 700 * 1024 * 1024; // 700 MB
const GENERAL_MAX_HEAP_SIZE = 700 * 2 * 1024 * 1024; // 1400 MB
export const MAX_FILE_SIZE = process.arch === 'ia32' ? WIN32_MAX_FILE_SIZE : GENERAL_MAX_FILE_SIZE;
export const MAX_HEAP_SIZE = process.arch === 'ia32' ? WIN32_MAX_HEAP_SIZE : GENERAL_MAX_HEAP_SIZE;
+1 -1
View File
@@ -159,7 +159,7 @@ export function asText(context: IRequestContext): Promise<string | null> {
});
}
export function asJson<T>(context: IRequestContext): Promise<T | null> {
export function asJson<T = {}>(context: IRequestContext): Promise<T | null> {
return new Promise((c, e) => {
if (!isSuccess(context)) {
return e('Server returned ' + context.res.statusCode);
+1 -1
View File
@@ -218,7 +218,7 @@ class ProtocolReader extends Disposable {
// save new state => next time will read the body
this._state.readHead = false;
this._state.readLen = buff.readUInt32BE(9);
this._state.messageType = <ProtocolMessageType>buff.readUInt8(0);
this._state.messageType = buff.readUInt8(0);
this._state.id = buff.readUInt32BE(1);
this._state.ack = buff.readUInt32BE(5);
} else {
@@ -36,11 +36,11 @@ let IDS = 0;
export class QuickOpenItemAccessorClass implements IItemAccessor<QuickOpenEntry> {
getItemLabel(entry: QuickOpenEntry): string | null {
return entry.getLabel();
return types.withUndefinedAsNull(entry.getLabel());
}
getItemDescription(entry: QuickOpenEntry): string | null {
return entry.getDescription();
return types.withUndefinedAsNull(entry.getDescription());
}
getItemPath(entry: QuickOpenEntry): string | undefined {
@@ -75,15 +75,15 @@ export class QuickOpenEntry {
/**
* The label of the entry to identify it from others in the list
*/
getLabel(): string | null {
return null;
getLabel(): string | undefined {
return undefined;
}
/**
* The options for the label to use for this entry
*/
getLabelOptions(): IIconLabelValueOptions | null {
return null;
getLabelOptions(): IIconLabelValueOptions | undefined {
return undefined;
}
/**
@@ -97,51 +97,51 @@ export class QuickOpenEntry {
/**
* Detail information about the entry that is optional and can be shown below the label
*/
getDetail(): string | null {
return null;
getDetail(): string | undefined {
return undefined;
}
/**
* The icon of the entry to identify it from others in the list
*/
getIcon(): string | null {
return null;
getIcon(): string | undefined {
return undefined;
}
/**
* A secondary description that is optional and can be shown right to the label
*/
getDescription(): string | null {
return null;
getDescription(): string | undefined {
return undefined;
}
/**
* A tooltip to show when hovering over the entry.
*/
getTooltip(): string | null {
return null;
getTooltip(): string | undefined {
return undefined;
}
/**
* A tooltip to show when hovering over the description portion of the entry.
*/
getDescriptionTooltip(): string | null {
return null;
getDescriptionTooltip(): string | undefined {
return undefined;
}
/**
* An optional keybinding to show for an entry.
*/
getKeybinding(): ResolvedKeybinding | null {
return null;
getKeybinding(): ResolvedKeybinding | undefined {
return undefined;
}
/**
* A resource for this entry. Resource URIs can be used to compare different kinds of entries and group
* them together.
*/
getResource(): URI | null {
return null;
getResource(): URI | undefined {
return undefined;
}
/**
@@ -229,11 +229,11 @@ export class QuickOpenEntryGroup extends QuickOpenEntry {
this.withBorder = showBorder;
}
getLabel(): string | null {
getLabel(): string | undefined {
return this.entry ? this.entry.getLabel() : super.getLabel();
}
getLabelOptions(): IIconLabelValueOptions | null {
getLabelOptions(): IIconLabelValueOptions | undefined {
return this.entry ? this.entry.getLabelOptions() : super.getLabelOptions();
}
@@ -241,19 +241,19 @@ export class QuickOpenEntryGroup extends QuickOpenEntry {
return this.entry ? this.entry.getAriaLabel() : super.getAriaLabel();
}
getDetail(): string | null {
getDetail(): string | undefined {
return this.entry ? this.entry.getDetail() : super.getDetail();
}
getResource(): URI | null {
getResource(): URI | undefined {
return this.entry ? this.entry.getResource() : super.getResource();
}
getIcon(): string | null {
getIcon(): string | undefined {
return this.entry ? this.entry.getIcon() : super.getIcon();
}
getDescription(): string | null {
getDescription(): string | undefined {
return this.entry ? this.entry.getDescription() : super.getDescription();
}
@@ -459,13 +459,13 @@ class Renderer implements IRenderer<QuickOpenEntry> {
// Label
const options: IIconLabelValueOptions = entry.getLabelOptions() || Object.create(null);
options.matches = labelHighlights || [];
options.title = types.withNullAsUndefined(entry.getTooltip());
options.descriptionTitle = entry.getDescriptionTooltip() || types.withNullAsUndefined(entry.getDescription()); // tooltip over description because it could overflow
options.title = entry.getTooltip();
options.descriptionTitle = entry.getDescriptionTooltip() || entry.getDescription(); // tooltip over description because it could overflow
options.descriptionMatches = descriptionHighlights || [];
data.label.setLabel(types.withNullAsUndefined(entry.getLabel()), types.withNullAsUndefined(entry.getDescription()), options);
data.label.setLabel(types.withNullAsUndefined(entry.getLabel()), entry.getDescription(), options);
// Meta
data.detail.set(types.withNullAsUndefined(entry.getDetail()), detailHighlights);
data.detail.set(entry.getDetail(), detailHighlights);
// Keybinding
data.keybinding.set(entry.getKeybinding()!);
@@ -556,7 +556,7 @@ export class QuickOpenModel implements
}
getLabel(entry: QuickOpenEntry): string | null {
return entry.getLabel();
return types.withUndefinedAsNull(entry.getLabel());
}
getAriaLabel(entry: QuickOpenEntry): string {
+6
View File
@@ -6,6 +6,7 @@ import * as assert from 'assert';
import { guessMimeTypes, registerTextMime, suggestFilename } from 'vs/base/common/mime';
suite('Mime', () => {
test('Dynamically Register Text Mime', () => {
let guess = guessMimeTypes('foo.monaco');
assert.deepEqual(guess, ['application/unknown']);
@@ -56,6 +57,11 @@ suite('Mime', () => {
registerTextMime({ id: 'docker', filepattern: 'dockerfile*', mime: 'text/looser' });
guess = guessMimeTypes('dockerfile');
assert.deepEqual(guess, ['text/winner', 'text/plain']);
registerTextMime({ id: 'azure-looser', mime: 'text/azure-looser', firstline: /azure/ });
registerTextMime({ id: 'azure-winner', mime: 'text/azure-winner', firstline: /azure/ });
guess = guessMimeTypes('azure', 'azure');
assert.deepEqual(guess, ['text/azure-winner', 'text/plain']);
});
test('Specificity priority 1', () => {
+20 -2
View File
@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { dirname, basename, distinctParents, joinPath, isEqual, isEqualOrParent, hasToIgnoreCase, normalizePath, isAbsolutePath, relativePath, removeTrailingPathSeparator, hasTrailingPathSeparator, resolvePath } from 'vs/base/common/resources';
import { dirname, basename, distinctParents, joinPath, isEqual, isEqualOrParent, hasToIgnoreCase, normalizePath, isAbsolutePath, relativePath, removeTrailingPathSeparator, hasTrailingPathSeparator, resolvePath, addTrailingPathSeparator } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { isWindows } from 'vs/base/common/platform';
import { toSlashes } from 'vs/base/common/extpath';
@@ -178,6 +178,9 @@ suite('Resources', () => {
assertEqualURI(removeTrailingPathSeparator(u1), expected, u1.toString());
}
function assertAddTrailingSeparator(u1: URI, expected: URI) {
assertEqualURI(addTrailingPathSeparator(u1), expected, u1.toString());
}
test('trailingPathSeparator', () => {
assertTrailingSeparator(URI.parse('foo://a/foo'), false);
@@ -190,6 +193,11 @@ suite('Resources', () => {
assertRemoveTrailingSeparator(URI.parse('foo://a/'), URI.parse('foo://a/'));
assertRemoveTrailingSeparator(URI.parse('foo://a'), URI.parse('foo://a'));
assertAddTrailingSeparator(URI.parse('foo://a/foo'), URI.parse('foo://a/foo/'));
assertAddTrailingSeparator(URI.parse('foo://a/foo/'), URI.parse('foo://a/foo/'));
assertAddTrailingSeparator(URI.parse('foo://a/'), URI.parse('foo://a/'));
assertAddTrailingSeparator(URI.parse('foo://a'), URI.parse('foo://a/'));
if (isWindows) {
assertTrailingSeparator(URI.file('c:\\a\\foo'), false);
assertTrailingSeparator(URI.file('c:\\a\\foo\\'), true);
@@ -202,6 +210,12 @@ suite('Resources', () => {
assertRemoveTrailingSeparator(URI.file('c:\\'), URI.file('c:\\'));
assertRemoveTrailingSeparator(URI.file('\\\\server\\share\\some\\'), URI.file('\\\\server\\share\\some'));
assertRemoveTrailingSeparator(URI.file('\\\\server\\share\\'), URI.file('\\\\server\\share\\'));
assertAddTrailingSeparator(URI.file('c:\\a\\foo'), URI.file('c:\\a\\foo\\'));
assertAddTrailingSeparator(URI.file('c:\\a\\foo\\'), URI.file('c:\\a\\foo\\'));
assertAddTrailingSeparator(URI.file('c:\\'), URI.file('c:\\'));
assertAddTrailingSeparator(URI.file('\\\\server\\share\\some'), URI.file('\\\\server\\share\\some\\'));
assertAddTrailingSeparator(URI.file('\\\\server\\share\\some\\'), URI.file('\\\\server\\share\\some\\'));
} else {
assertTrailingSeparator(URI.file('/foo/bar'), false);
assertTrailingSeparator(URI.file('/foo/bar/'), true);
@@ -210,12 +224,16 @@ suite('Resources', () => {
assertRemoveTrailingSeparator(URI.file('/foo/bar'), URI.file('/foo/bar'));
assertRemoveTrailingSeparator(URI.file('/foo/bar/'), URI.file('/foo/bar'));
assertRemoveTrailingSeparator(URI.file('/'), URI.file('/'));
assertAddTrailingSeparator(URI.file('/foo/bar'), URI.file('/foo/bar/'));
assertAddTrailingSeparator(URI.file('/foo/bar/'), URI.file('/foo/bar/'));
assertAddTrailingSeparator(URI.file('/'), URI.file('/'));
}
});
function assertEqualURI(actual: URI, expected: URI, message?: string) {
if (!isEqual(expected, actual)) {
assert.equal(expected.toString(), actual.toString(), message);
assert.equal(actual.toString(), expected.toString(), message);
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ suite('Config', () => {
const newDir = path.join(parentDir, 'config', id);
const testFile = path.join(newDir, 'config.json');
let watcher = new ConfigWatcher(testFile);
let watcher = new ConfigWatcher<{}>(testFile);
let config = watcher.getConfig();
assert.ok(config);
@@ -0,0 +1,15 @@
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!-- Disable pinch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body class="vs-dark" aria-label="">
</body>
<!-- Startup via workbench.js -->
<script src="../../../../../out/vs/code/browser/workbench/workbench.js"></script>
</html>
@@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
'use strict';
(function () {
function loadScript(path, callback) {
let script = document.createElement('script');
script.onload = callback;
script.async = true;
script.type = 'text/javascript';
script.src = path;
document.head.appendChild(script);
}
loadScript('../../../../../out/vs/loader.js', function () {
// @ts-ignore
require.config({
baseUrl: `${window.location.origin}/out`
});
// @ts-ignore
require([
'vs/workbench/workbench.web.main',
'vs/nls!vs/workbench/workbench.web.main',
'vs/css!vs/workbench/workbench.web.main'
],
// @ts-ignore
function () {
// @ts-ignore
require('vs/workbench/browser/web.main').main().then(undefined, console.error);
});
});
})();
@@ -106,8 +106,8 @@ function showPartsSplash(configuration) {
const style = document.createElement('style');
style.className = 'initialShellColors';
document.head.appendChild(style);
document.body.className = `monaco-shell ${baseTheme}`;
style.innerHTML = `.monaco-shell { background-color: ${shellBackground}; color: ${shellForeground}; }`;
document.body.className = baseTheme;
style.innerHTML = `body { background-color: ${shellBackground}; color: ${shellForeground}; }`;
if (data && data.layoutInfo) {
// restore parts if possible (we might not always store layout info)
@@ -1,12 +0,0 @@
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body class="monaco-shell vs-dark" aria-label="">
</body>
<!-- Startup via workbench.nodeless.js -->
<script src="workbench.nodeless.js"></script>
</html>
@@ -1,67 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
'use strict';
(function () {
function uriFromPath(_path) {
let pathName = _path.replace(/\\/g, '/');
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
pathName = '/' + pathName;
}
let uri;
if (navigator.userAgent.indexOf('Windows') >= 0 && pathName.startsWith('//')) { // specially handle Windows UNC paths
uri = encodeURI('file:' + pathName);
} else {
uri = encodeURI('file://' + pathName);
}
return uri.replace(/#/g, '%23');
}
function parseURLQueryArgs() {
const search = window.location.search || '';
return search.split(/[?&]/)
.filter(function (param) { return !!param; })
.map(function (param) { return param.split('='); })
.filter(function (param) { return param.length === 2; })
.reduce(function (r, param) { r[param[0]] = decodeURIComponent(param[1]); return r; }, {});
}
function loadScript(path, callback) {
let script = document.createElement('script');
script.onload = callback;
script.async = true;
script.type = 'text/javascript';
script.src = path;
document.head.appendChild(script);
}
loadScript('../../../../../out/vs/loader.js', function () {
const args = parseURLQueryArgs();
const configuration = JSON.parse(args['config'] || '{}') || {};
// @ts-ignore
require.config({
baseUrl: uriFromPath(configuration.appRoot) + '/out',
});
// @ts-ignore
require([
'vs/workbench/workbench.nodeless.main',
'vs/nls!vs/workbench/workbench.nodeless.main',
'vs/css!vs/workbench/workbench.nodeless.main'
], function () {
// @ts-ignore
require('vs/workbench/browser/nodeless.main').main().then(undefined, console.error);
});
});
})();
+2 -2
View File
@@ -234,7 +234,7 @@ export class CodeApplication extends Disposable {
ipc.on('vscode:fetchShellEnv', (event: Event) => {
const webContents = event.sender;
getShellEnvironment().then(shellEnv => {
getShellEnvironment(this.logService).then(shellEnv => {
if (!webContents.isDestroyed()) {
webContents.send('vscode:acceptShellEnv', shellEnv);
}
@@ -678,7 +678,7 @@ export class CodeApplication extends Disposable {
historyMainService.onRecentlyOpenedChange(() => historyMainService.updateWindowsJumpList());
// Start shared process after a while
const sharedProcessSpawn = this._register(new RunOnceScheduler(() => getShellEnvironment().then(userEnv => this.sharedProcess.spawn(userEnv)), 3000));
const sharedProcessSpawn = this._register(new RunOnceScheduler(() => getShellEnvironment(this.logService).then(userEnv => this.sharedProcess.spawn(userEnv)), 3000));
sharedProcessSpawn.schedule();
}
+1 -1
View File
@@ -55,7 +55,7 @@ function setupIPC(accessor: ServicesAccessor): Promise<Server> {
logService.trace('Sending some foreground love to the running instance:', processId);
try {
const { allowSetForegroundWindow } = <any>require.__$__nodeRequire('windows-foreground-love');
const { allowSetForegroundWindow } = require.__$__nodeRequire('windows-foreground-love');
allowSetForegroundWindow(processId);
} catch (e) {
// noop
+47 -55
View File
@@ -8,7 +8,7 @@ import * as objects from 'vs/base/common/objects';
import * as nls from 'vs/nls';
import { URI } from 'vs/base/common/uri';
import { IStateService } from 'vs/platform/state/common/state';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage } from 'electron';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display } from 'electron';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -25,7 +25,6 @@ import * as perf from 'vs/base/common/performance';
import { resolveMarketplaceHeaders } from 'vs/platform/extensionManagement/node/extensionGalleryService';
import { getBackgroundColor } from 'vs/code/electron-main/theme';
import { RunOnceScheduler } from 'vs/base/common/async';
import { withNullAsUndefined } from 'vs/base/common/types';
import { endsWith } from 'vs/base/common/strings';
export interface IWindowCreationOptions {
@@ -80,8 +79,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private readonly touchBarGroups: Electron.TouchBarSegmentedControl[];
private nodeless: boolean;
constructor(
config: IWindowCreationOptions,
@ILogService private readonly logService: ILogService,
@@ -98,8 +95,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this._readyState = ReadyState.NONE;
this.whenReadyCallbacks = [];
this.nodeless = !!(environmentService.args.nodeless && !environmentService.isBuilt);
// create browser window
this.createBrowserWindow(config);
@@ -129,7 +124,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
height: this.windowState.height,
x: this.windowState.x,
y: this.windowState.y,
backgroundColor: this.nodeless ? undefined : getBackgroundColor(this.stateService),
backgroundColor: getBackgroundColor(this.stateService),
minWidth: CodeWindow.MIN_WIDTH,
minHeight: CodeWindow.MIN_HEIGHT,
show: !isFullscreenOrMaximized,
@@ -143,10 +138,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
};
if (this.nodeless) {
options.webPreferences!.nodeIntegration = false; // simulate Electron 5 behaviour
}
if (isLinux) {
options.icon = path.join(this.environmentService.appRoot, 'resources/linux/code.png'); // Windows and Mac are better off using the embedded icon(s)
}
@@ -201,10 +192,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
}
if (this.nodeless) {
this._win.webContents.toggleDevTools();
}
this._lastFocusTime = Date.now(); // since we show directly, we need to set the last focus time too
}
@@ -640,10 +627,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
private doGetUrl(config: object): string {
if (this.nodeless) {
return `${require.toUrl('vs/code/electron-browser/workbench/workbench.nodeless.html')}?config=${encodeURIComponent(JSON.stringify(config))}`;
}
return `${require.toUrl('vs/code/electron-browser/workbench/workbench.html')}?config=${encodeURIComponent(JSON.stringify(config))}`;
}
@@ -709,66 +692,55 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private restoreWindowState(state?: IWindowState): IWindowState {
if (state) {
try {
state = withNullAsUndefined(this.validateWindowState(state));
state = this.validateWindowState(state);
} catch (err) {
this.logService.warn(`Unexpected error validating window state: ${err}\n${err.stack}`); // somehow display API can be picky about the state to validate
}
}
if (!state) {
state = defaultWindowState();
}
return state;
return state || defaultWindowState();
}
private validateWindowState(state: IWindowState): IWindowState | null {
if (!state) {
return null;
}
private validateWindowState(state: IWindowState): IWindowState | undefined {
if (typeof state.x !== 'number'
|| typeof state.y !== 'number'
|| typeof state.width !== 'number'
|| typeof state.height !== 'number'
) {
return null;
return undefined;
}
if (state.width <= 0 || state.height <= 0) {
return null;
return undefined;
}
const displays = screen.getAllDisplays();
// Single Monitor: be strict about x/y positioning
if (displays.length === 1) {
const displayBounds = displays[0].bounds;
// Careful with maximized: in that mode x/y can well be negative!
if (state.mode !== WindowMode.Maximized && displayBounds.width > 0 && displayBounds.height > 0 /* Linux X11 sessions sometimes report wrong display bounds */) {
if (state.x < displayBounds.x) {
state.x = displayBounds.x; // prevent window from falling out of the screen to the left
const displayWorkingArea = this.getWorkingArea(displays[0]);
if (state.mode !== WindowMode.Maximized && displayWorkingArea) {
if (state.x < displayWorkingArea.x) {
state.x = displayWorkingArea.x; // prevent window from falling out of the screen to the left
}
if (state.y < displayBounds.y) {
state.y = displayBounds.y; // prevent window from falling out of the screen to the top
if (state.y < displayWorkingArea.y) {
state.y = displayWorkingArea.y; // prevent window from falling out of the screen to the top
}
if (state.x > (displayBounds.x + displayBounds.width)) {
state.x = displayBounds.x; // prevent window from falling out of the screen to the right
if (state.x > (displayWorkingArea.x + displayWorkingArea.width)) {
state.x = displayWorkingArea.x; // prevent window from falling out of the screen to the right
}
if (state.y > (displayBounds.y + displayBounds.height)) {
state.y = displayBounds.y; // prevent window from falling out of the screen to the bottom
if (state.y > (displayWorkingArea.y + displayWorkingArea.height)) {
state.y = displayWorkingArea.y; // prevent window from falling out of the screen to the bottom
}
if (state.width > displayBounds.width) {
state.width = displayBounds.width; // prevent window from exceeding display bounds width
if (state.width > displayWorkingArea.width) {
state.width = displayWorkingArea.width; // prevent window from exceeding display bounds width
}
if (state.height > displayBounds.height) {
state.height = displayBounds.height; // prevent window from exceeding display bounds height
if (state.height > displayWorkingArea.height) {
state.height = displayWorkingArea.height; // prevent window from exceeding display bounds height
}
}
@@ -794,12 +766,14 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// Multi Monitor (non-fullscreen): be less strict because metrics can be crazy
const bounds = { x: state.x, y: state.y, width: state.width, height: state.height };
const display = screen.getDisplayMatching(bounds);
const displayWorkingArea = this.getWorkingArea(display);
if (
display && // we have a display matching the desired bounds
bounds.x < display.bounds.x + display.bounds.width && // prevent window from falling out of the screen to the right
bounds.y < display.bounds.y + display.bounds.height && // prevent window from falling out of the screen to the bottom
bounds.x + bounds.width > display.bounds.x && // prevent window from falling out of the screen to the left
bounds.y + bounds.height > display.bounds.y // prevent window from falling out of the scree nto the top
display && // we have a display matching the desired bounds
displayWorkingArea && // we have valid working area bounds
bounds.x < displayWorkingArea.x + displayWorkingArea.width && // prevent window from falling out of the screen to the right
bounds.y < displayWorkingArea.y + displayWorkingArea.height && // prevent window from falling out of the screen to the bottom
bounds.x + bounds.width > displayWorkingArea.x && // prevent window from falling out of the screen to the left
bounds.y + bounds.height > displayWorkingArea.y // prevent window from falling out of the scree nto the top
) {
if (state.mode === WindowMode.Maximized) {
const defaults = defaultWindowState(WindowMode.Maximized); // when maximized, make sure we have good values when the user restores the window
@@ -812,7 +786,25 @@ export class CodeWindow extends Disposable implements ICodeWindow {
return state;
}
return null;
return undefined;
}
private getWorkingArea(display: Display): Rectangle | undefined {
// Prefer the working area of the display to account for taskbars on the
// desktop being positioned somewhere (https://github.com/Microsoft/vscode/issues/50830).
//
// Linux X11 sessions sometimes report wrong display bounds, so we validate
// the reported sizes are positive.
if (display.workArea.width > 0 && display.workArea.height > 0) {
return display.workArea;
}
if (display.bounds.width > 0 && display.bounds.height > 0) {
return display.bounds;
}
return undefined;
}
getBounds(): Electron.Rectangle {
+11 -9
View File
@@ -112,6 +112,10 @@ export class Main {
private async installExtensions(extensions: string[], force: boolean): Promise<void> {
const failed: string[] = [];
const installedExtensionsManifests: IExtensionManifest[] = [];
if (extensions.length) {
console.log(localize('installingExtensions', "Installing extensions..."));
}
for (const extension of extensions) {
try {
const manifest = await this.installExtension(extension, force);
@@ -142,11 +146,11 @@ export class Main {
if (valid) {
return this.extensionManagementService.install(URI.file(extension)).then(id => {
console.log(localize('successVsixInstall', "Extension '{0}' was successfully installed!", getBaseLabel(extension)));
console.log(localize('successVsixInstall', "Extension '{0}' was successfully installed.", getBaseLabel(extension)));
return manifest;
}, error => {
if (isPromiseCanceledError(error)) {
console.log(localize('cancelVsixInstall', "Cancelled installing Extension '{0}'.", getBaseLabel(extension)));
console.log(localize('cancelVsixInstall', "Cancelled installing extension '{0}'.", getBaseLabel(extension)));
return null;
} else {
return Promise.reject(error);
@@ -191,9 +195,7 @@ export class Main {
console.log(localize('forceUpdate', "Extension '{0}' v{1} is already installed, but a newer version {2} is available in the marketplace. Use '--force' option to update to newer version.", id, installedExtension.manifest.version, extension.version));
return Promise.resolve(null);
}
console.log(localize('updateMessage', "Updating the Extension '{0}' to the version {1}", id, extension.version));
} else {
console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id));
console.log(localize('updateMessage', "Updating the extension '{0}' to the version {1}", id, extension.version));
}
await this.installFromGallery(id, extension);
return manifest;
@@ -210,7 +212,7 @@ export class Main {
const newer = installedExtensions.filter(local => areSameExtensions(extensionIdentifier, local.identifier) && semver.gt(local.manifest.version, manifest.version))[0];
if (newer && !force) {
console.log(localize('forceDowngrade', "A newer version of this extension '{0}' v{1} is already installed. Use '--force' option to downgrade to older version.", newer.identifier.id, newer.manifest.version, manifest.version));
console.log(localize('forceDowngrade', "A newer version of extension '{0}' v{1} is already installed. Use '--force' option to downgrade to older version.", newer.identifier.id, newer.manifest.version, manifest.version));
return false;
}
@@ -218,14 +220,14 @@ export class Main {
}
private async installFromGallery(id: string, extension: IGalleryExtension): Promise<void> {
console.log(localize('installing', "Installing..."));
console.log(localize('installing', "Installing extension '{0}' v{1}...", id, extension.version));
try {
await this.extensionManagementService.installFromGallery(extension);
console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed!", id, extension.version));
console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed.", id, extension.version));
} catch (error) {
if (isPromiseCanceledError(error)) {
console.log(localize('cancelVsixInstall', "Cancelled installing Extension '{0}'.", id));
console.log(localize('cancelVsixInstall', "Cancelled installing extension '{0}'.", id));
} else {
throw error;
}
+18 -3
View File
@@ -7,11 +7,16 @@ import * as cp from 'child_process';
import { assign } from 'vs/base/common/objects';
import { generateUuid } from 'vs/base/common/uuid';
import { isWindows } from 'vs/base/common/platform';
import { ILogService } from 'vs/platform/log/common/log';
function getUnixShellEnvironment(): Promise<typeof process.env> {
function getUnixShellEnvironment(logService: ILogService): Promise<typeof process.env> {
const promise = new Promise<typeof process.env>((resolve, reject) => {
const runAsNode = process.env['ELECTRON_RUN_AS_NODE'];
logService.trace('getUnixShellEnvironment#runAsNode', runAsNode);
const noAttach = process.env['ELECTRON_NO_ATTACH_CONSOLE'];
logService.trace('getUnixShellEnvironment#noAttach', noAttach);
const mark = generateUuid().replace(/-/g, '').substr(0, 12);
const regex = new RegExp(mark + '(.*)' + mark);
@@ -21,6 +26,9 @@ function getUnixShellEnvironment(): Promise<typeof process.env> {
});
const command = `'${process.execPath}' -p '"${mark}" + JSON.stringify(process.env) + "${mark}"'`;
logService.trace('getUnixShellEnvironment#env', env);
logService.trace('getUnixShellEnvironment#spawn', command);
const child = cp.spawn(process.env.SHELL!, ['-ilc', command], {
detached: true,
stdio: ['ignore', 'pipe', process.stderr],
@@ -37,6 +45,8 @@ function getUnixShellEnvironment(): Promise<typeof process.env> {
}
const raw = Buffer.concat(buffers).toString('utf8');
logService.trace('getUnixShellEnvironment#raw', raw);
const match = regex.exec(raw);
const rawStripped = match ? match[1] : '{}';
@@ -58,8 +68,10 @@ function getUnixShellEnvironment(): Promise<typeof process.env> {
// https://github.com/Microsoft/vscode/issues/22593#issuecomment-336050758
delete env['XDG_RUNTIME_DIR'];
logService.trace('getUnixShellEnvironment#result', env);
resolve(env);
} catch (err) {
logService.error('getUnixShellEnvironment#error', err);
reject(err);
}
});
@@ -77,14 +89,17 @@ let _shellEnv: Promise<typeof process.env>;
* This should only be done when Code itself is not launched
* from within a shell.
*/
export function getShellEnvironment(): Promise<typeof process.env> {
export function getShellEnvironment(logService: ILogService): Promise<typeof process.env> {
if (_shellEnv === undefined) {
if (isWindows) {
logService.trace('getShellEnvironment: runing on windows, skipping');
_shellEnv = Promise.resolve({});
} else if (process.env['VSCODE_CLI'] === '1') {
logService.trace('getShellEnvironment: runing on CLI, skipping');
_shellEnv = Promise.resolve({});
} else {
_shellEnv = getUnixShellEnvironment();
logService.trace('getShellEnvironment: running on Unix');
_shellEnv = getUnixShellEnvironment(logService);
}
}
@@ -301,13 +301,13 @@ export namespace CoreNavigationCommands {
export const MoveTo: CoreEditorCommand = registerEditorCommand(new BaseMoveToCommand({
id: '_moveTo',
inSelectionMode: false,
precondition: null
precondition: undefined
}));
export const MoveToSelect: CoreEditorCommand = registerEditorCommand(new BaseMoveToCommand({
id: '_moveToSelect',
inSelectionMode: true,
precondition: null
precondition: undefined
}));
abstract class ColumnSelectCommand extends CoreEditorCommand {
@@ -330,7 +330,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'columnSelect',
precondition: null
precondition: undefined
});
}
@@ -354,7 +354,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'cursorColumnSelectLeft',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -373,7 +373,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'cursorColumnSelectRight',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -405,7 +405,7 @@ export namespace CoreNavigationCommands {
export const CursorColumnSelectUp: CoreEditorCommand = registerEditorCommand(new ColumnSelectUpCommand({
isPaged: false,
id: 'cursorColumnSelectUp',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -417,7 +417,7 @@ export namespace CoreNavigationCommands {
export const CursorColumnSelectPageUp: CoreEditorCommand = registerEditorCommand(new ColumnSelectUpCommand({
isPaged: true,
id: 'cursorColumnSelectPageUp',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -443,7 +443,7 @@ export namespace CoreNavigationCommands {
export const CursorColumnSelectDown: CoreEditorCommand = registerEditorCommand(new ColumnSelectDownCommand({
isPaged: false,
id: 'cursorColumnSelectDown',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -455,7 +455,7 @@ export namespace CoreNavigationCommands {
export const CursorColumnSelectPageDown: CoreEditorCommand = registerEditorCommand(new ColumnSelectDownCommand({
isPaged: true,
id: 'cursorColumnSelectPageDown',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -468,7 +468,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'cursorMove',
precondition: null,
precondition: undefined,
description: CursorMove_.description
});
}
@@ -531,7 +531,7 @@ export namespace CoreNavigationCommands {
value: 1
},
id: 'cursorLeft',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -548,7 +548,7 @@ export namespace CoreNavigationCommands {
value: 1
},
id: 'cursorLeftSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -564,7 +564,7 @@ export namespace CoreNavigationCommands {
value: 1
},
id: 'cursorRight',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -581,7 +581,7 @@ export namespace CoreNavigationCommands {
value: 1
},
id: 'cursorRightSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -597,7 +597,7 @@ export namespace CoreNavigationCommands {
value: 1
},
id: 'cursorUp',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -614,7 +614,7 @@ export namespace CoreNavigationCommands {
value: 1
},
id: 'cursorUpSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -633,7 +633,7 @@ export namespace CoreNavigationCommands {
value: Constants.PAGE_SIZE_MARKER
},
id: 'cursorPageUp',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -649,7 +649,7 @@ export namespace CoreNavigationCommands {
value: Constants.PAGE_SIZE_MARKER
},
id: 'cursorPageUpSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -665,7 +665,7 @@ export namespace CoreNavigationCommands {
value: 1
},
id: 'cursorDown',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -682,7 +682,7 @@ export namespace CoreNavigationCommands {
value: 1
},
id: 'cursorDownSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -701,7 +701,7 @@ export namespace CoreNavigationCommands {
value: Constants.PAGE_SIZE_MARKER
},
id: 'cursorPageDown',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -717,7 +717,7 @@ export namespace CoreNavigationCommands {
value: Constants.PAGE_SIZE_MARKER
},
id: 'cursorPageDownSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -729,7 +729,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'createCursor',
precondition: null
precondition: undefined
});
}
@@ -790,7 +790,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: '_lastCursorMoveToSelect',
precondition: null
precondition: undefined
});
}
@@ -835,7 +835,7 @@ export namespace CoreNavigationCommands {
export const CursorHome: CoreEditorCommand = registerEditorCommand(new HomeCommand({
inSelectionMode: false,
id: 'cursorHome',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -847,7 +847,7 @@ export namespace CoreNavigationCommands {
export const CursorHomeSelect: CoreEditorCommand = registerEditorCommand(new HomeCommand({
inSelectionMode: true,
id: 'cursorHomeSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -860,7 +860,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'cursorLineStart',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -914,7 +914,7 @@ export namespace CoreNavigationCommands {
export const CursorEnd: CoreEditorCommand = registerEditorCommand(new EndCommand({
inSelectionMode: false,
id: 'cursorEnd',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -926,7 +926,7 @@ export namespace CoreNavigationCommands {
export const CursorEndSelect: CoreEditorCommand = registerEditorCommand(new EndCommand({
inSelectionMode: true,
id: 'cursorEndSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -939,7 +939,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'cursorLineEnd',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -994,7 +994,7 @@ export namespace CoreNavigationCommands {
export const CursorTop: CoreEditorCommand = registerEditorCommand(new TopCommand({
inSelectionMode: false,
id: 'cursorTop',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1006,7 +1006,7 @@ export namespace CoreNavigationCommands {
export const CursorTopSelect: CoreEditorCommand = registerEditorCommand(new TopCommand({
inSelectionMode: true,
id: 'cursorTopSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1038,7 +1038,7 @@ export namespace CoreNavigationCommands {
export const CursorBottom: CoreEditorCommand = registerEditorCommand(new BottomCommand({
inSelectionMode: false,
id: 'cursorBottom',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1050,7 +1050,7 @@ export namespace CoreNavigationCommands {
export const CursorBottomSelect: CoreEditorCommand = registerEditorCommand(new BottomCommand({
inSelectionMode: true,
id: 'cursorBottomSelect',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1063,7 +1063,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'editorScroll',
precondition: null,
precondition: undefined,
description: EditorScroll_.description
});
}
@@ -1134,7 +1134,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'scrollLineUp',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1159,7 +1159,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'scrollPageUp',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1185,7 +1185,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'scrollLineDown',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1210,7 +1210,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'scrollPageDown',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1257,20 +1257,20 @@ export namespace CoreNavigationCommands {
export const WordSelect: CoreEditorCommand = registerEditorCommand(new WordCommand({
inSelectionMode: false,
id: '_wordSelect',
precondition: null
precondition: undefined
}));
export const WordSelectDrag: CoreEditorCommand = registerEditorCommand(new WordCommand({
inSelectionMode: true,
id: '_wordSelectDrag',
precondition: null
precondition: undefined
}));
export const LastCursorWordSelect: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand {
constructor() {
super({
id: 'lastCursorWordSelect',
precondition: null
precondition: undefined
});
}
@@ -1317,13 +1317,13 @@ export namespace CoreNavigationCommands {
export const LineSelect: CoreEditorCommand = registerEditorCommand(new LineCommand({
inSelectionMode: false,
id: '_lineSelect',
precondition: null
precondition: undefined
}));
export const LineSelectDrag: CoreEditorCommand = registerEditorCommand(new LineCommand({
inSelectionMode: true,
id: '_lineSelectDrag',
precondition: null
precondition: undefined
}));
class LastCursorLineCommand extends CoreEditorCommand {
@@ -1353,20 +1353,20 @@ export namespace CoreNavigationCommands {
export const LastCursorLineSelect: CoreEditorCommand = registerEditorCommand(new LastCursorLineCommand({
inSelectionMode: false,
id: 'lastCursorLineSelect',
precondition: null
precondition: undefined
}));
export const LastCursorLineSelectDrag: CoreEditorCommand = registerEditorCommand(new LastCursorLineCommand({
inSelectionMode: true,
id: 'lastCursorLineSelectDrag',
precondition: null
precondition: undefined
}));
export const ExpandLineSelection: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand {
constructor() {
super({
id: 'expandLineSelection',
precondition: null,
precondition: undefined,
kbOpts: {
weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus,
@@ -1445,7 +1445,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'revealLine',
precondition: null,
precondition: undefined,
description: RevealLine_.description
});
}
@@ -1493,7 +1493,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'selectAll',
precondition: null
precondition: undefined
});
}
@@ -1513,7 +1513,7 @@ export namespace CoreNavigationCommands {
constructor() {
super({
id: 'setSelection',
precondition: null
precondition: undefined
});
}
@@ -1728,7 +1728,7 @@ class EditorHandlerCommand extends Command {
constructor(id: string, handlerId: string, description?: ICommandHandlerDescription) {
super({
id: id,
precondition: null,
precondition: undefined,
description: description
});
this._handlerId = handlerId;
+6 -6
View File
@@ -40,17 +40,17 @@ export interface ICommandMenubarOptions {
}
export interface ICommandOptions {
id: string;
precondition: ContextKeyExpr | null;
kbOpts?: ICommandKeybindingsOptions | null;
precondition: ContextKeyExpr | undefined;
kbOpts?: ICommandKeybindingsOptions;
description?: ICommandHandlerDescription;
menubarOpts?: ICommandMenubarOptions;
}
export abstract class Command {
public readonly id: string;
public readonly precondition: ContextKeyExpr | null;
private readonly _kbOpts: ICommandKeybindingsOptions | null | undefined;
private readonly _menubarOpts: ICommandMenubarOptions | null | undefined;
private readonly _description: ICommandHandlerDescription | null | undefined;
public readonly precondition: ContextKeyExpr | undefined;
private readonly _kbOpts: ICommandKeybindingsOptions | undefined;
private readonly _menubarOpts: ICommandMenubarOptions | undefined;
private readonly _description: ICommandHandlerDescription | undefined;
constructor(opts: ICommandOptions) {
this.id = opts.id;
+42 -31
View File
@@ -19,14 +19,11 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
// Get the path and name of the resource. For data-URIs, we need to parse specially
let name: string | undefined;
let path: string | undefined;
if (resource.scheme === Schemas.data) {
const metadata = DataUri.parseMetaData(resource);
name = metadata.get(DataUri.META_DATA_LABEL);
path = name;
} else {
name = cssEscape(basenameOrAuthority(resource).toLowerCase());
path = resource.path.toLowerCase();
}
// Folders
@@ -47,46 +44,60 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
classes.push(`ext-file-icon`); // extra segment to increase file-ext score
}
// Configured Language
let configuredLangId: string | null = getConfiguredLangId(modelService, modeService, resource);
configuredLangId = configuredLangId || (path ? modeService.getModeIdByFilepathOrFirstLine(path) : null);
if (configuredLangId) {
classes.push(`${cssEscape(configuredLangId)}-lang-file-icon`);
// Detected Mode
const detectedModeId = detectModeId(modelService, modeService, resource);
if (detectedModeId) {
classes.push(`${cssEscape(detectedModeId)}-lang-file-icon`);
}
}
}
return classes;
}
export function getConfiguredLangId(modelService: IModelService, modeService: IModeService, resource: uri): string | null {
let configuredLangId: string | null = null;
if (resource) {
let modeId: string | null = null;
export function detectModeId(modelService: IModelService, modeService: IModeService, resource: uri): string | null {
if (!resource) {
return null; // we need a resource at least
}
// Data URI: check for encoded metadata
if (resource.scheme === Schemas.data) {
const metadata = DataUri.parseMetaData(resource);
const mime = metadata.get(DataUri.META_DATA_MIME);
let modeId: string | null = null;
if (mime) {
modeId = modeService.getModeId(mime);
}
}
// Data URI: check for encoded metadata
if (resource.scheme === Schemas.data) {
const metadata = DataUri.parseMetaData(resource);
const mime = metadata.get(DataUri.META_DATA_MIME);
// Any other URI: check for model if existing
else {
const model = modelService.getModel(resource);
if (model) {
modeId = model.getLanguageIdentifier().language;
}
}
if (modeId && modeId !== PLAINTEXT_MODE_ID) {
configuredLangId = modeId; // only take if the mode is specific (aka no just plain text)
if (mime) {
modeId = modeService.getModeId(mime);
}
}
return configuredLangId;
// Any other URI: check for model if existing
else {
const model = modelService.getModel(resource);
if (model) {
modeId = model.getModeId();
}
}
// only take if the mode is specific (aka no just plain text)
if (modeId && modeId !== PLAINTEXT_MODE_ID) {
return modeId;
}
// otherwise fallback to path based detection
let path: string | undefined;
if (resource.scheme === Schemas.data) {
const metadata = DataUri.parseMetaData(resource);
path = metadata.get(DataUri.META_DATA_LABEL);
} else {
path = resource.path.toLowerCase();
}
if (path) {
return modeService.getModeIdByFilepathOrFirstLine(path);
}
return null; // finally - we do not know the mode id
}
export function cssEscape(val: string): string {
@@ -5,7 +5,7 @@
import { IDisposable, IReference } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { ITextModel } from 'vs/editor/common/model';
import { ITextModel, ITextSnapshot } from 'vs/editor/common/model';
import { IEditorModel } from 'vs/platform/editor/common/editor';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@@ -46,6 +46,12 @@ export interface ITextEditorModel extends IEditorModel {
*/
readonly textEditorModel: ITextModel | null;
/**
* Creates a snapshot of the model's contents.
*/
createSnapshot(this: IResolvedTextEditorModel): ITextSnapshot;
createSnapshot(this: ITextEditorModel): ITextSnapshot | null;
isReadonly(): boolean;
}
@@ -31,7 +31,7 @@ class JumpToBracketAction extends EditorAction {
id: 'editor.action.jumpToBracket',
label: nls.localize('smartSelect.jumpBracket', "Go to Bracket"),
alias: 'Go to Bracket',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH,
@@ -55,7 +55,7 @@ class SelectToBracketAction extends EditorAction {
id: 'editor.action.selectToBracket',
label: nls.localize('smartSelect.selectToBracket', "Select to Bracket"),
alias: 'Select to Bracket',
precondition: null
precondition: undefined
});
}
+8 -8
View File
@@ -59,7 +59,7 @@ abstract class ExecCommandAction extends EditorAction {
class ExecCommandCutAction extends ExecCommandAction {
constructor() {
let kbOpts: ICommandKeybindingsOptions | null = {
let kbOpts: ICommandKeybindingsOptions | undefined = {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_X,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] },
@@ -68,7 +68,7 @@ class ExecCommandCutAction extends ExecCommandAction {
// Do not bind cut keybindings in the browser,
// since browsers do that for us and it avoids security prompts
if (!platform.isNative) {
kbOpts = null;
kbOpts = undefined;
}
super('cut', {
id: 'editor.action.clipboardCutAction',
@@ -107,7 +107,7 @@ class ExecCommandCutAction extends ExecCommandAction {
class ExecCommandCopyAction extends ExecCommandAction {
constructor() {
let kbOpts: ICommandKeybindingsOptions | null = {
let kbOpts: ICommandKeybindingsOptions | undefined = {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] },
@@ -116,14 +116,14 @@ class ExecCommandCopyAction extends ExecCommandAction {
// Do not bind copy keybindings in the browser,
// since browsers do that for us and it avoids security prompts
if (!platform.isNative) {
kbOpts = null;
kbOpts = undefined;
}
super('copy', {
id: 'editor.action.clipboardCopyAction',
label: nls.localize('actions.clipboard.copyLabel', "Copy"),
alias: 'Copy',
precondition: null,
precondition: undefined,
kbOpts: kbOpts,
menuOpts: {
group: CLIPBOARD_CONTEXT_MENU_GROUP,
@@ -162,7 +162,7 @@ class ExecCommandCopyAction extends ExecCommandAction {
class ExecCommandPasteAction extends ExecCommandAction {
constructor() {
let kbOpts: ICommandKeybindingsOptions | null = {
let kbOpts: ICommandKeybindingsOptions | undefined = {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] },
@@ -171,7 +171,7 @@ class ExecCommandPasteAction extends ExecCommandAction {
// Do not bind paste keybindings in the browser,
// since browsers do that for us and it avoids security prompts
if (!platform.isNative) {
kbOpts = null;
kbOpts = undefined;
}
super('paste', {
@@ -201,7 +201,7 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction {
id: 'editor.action.clipboardCopyWithSyntaxHighlightingAction',
label: nls.localize('actions.clipboard.copyWithSyntaxHighlightingLabel', "Copy With Syntax Highlighting"),
alias: 'Copy With Syntax Highlighting',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: 0,
@@ -34,8 +34,8 @@ export class CodeActionSet {
public readonly actions: readonly CodeAction[];
public constructor(actions: CodeAction[]) {
this.actions = mergeSort(actions, CodeActionSet.codeActionsComparator);
public constructor(actions: readonly CodeAction[]) {
this.actions = mergeSort([...actions], CodeActionSet.codeActionsComparator);
}
public get hasAutoFix() {
@@ -176,6 +176,7 @@ function showCodeActionsForEditorSelection(
return;
}
MessageController.get(editor).closeMessage();
const pos = editor.getPosition();
controller.triggerFromEditorSelection(filter, autoApply).then(codeActions => {
if (!codeActions || !codeActions.actions.length) {
@@ -20,8 +20,12 @@ export class CodeActionKind {
public readonly value: string
) { }
public equals(other: CodeActionKind): boolean {
return this.value === other.value;
}
public contains(other: CodeActionKind): boolean {
return this.value === other.value || startsWith(other.value, this.value + CodeActionKind.sep);
return this.equals(other) || startsWith(other.value, this.value + CodeActionKind.sep);
}
public intersects(other: CodeActionKind): boolean {
@@ -76,9 +76,9 @@ export class ColorDetector implements IEditorContribution {
}
const languageId = model.getLanguageIdentifier();
// handle deprecated settings. [languageId].colorDecorators.enable
let deprecatedConfig = this._configurationService.getValue(languageId.language);
const deprecatedConfig = this._configurationService.getValue<{}>(languageId.language);
if (deprecatedConfig) {
let colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
const colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
if (colorDecorators && colorDecorators['enable'] !== undefined && !colorDecorators['enable']) {
return colorDecorators['enable'];
}
@@ -6,7 +6,7 @@
import * as nls from 'vs/nls';
import * as dom from 'vs/base/browser/dom';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { ActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { ActionViewItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview';
import { IAction } from 'vs/base/common/actions';
import { KeyCode, KeyMod, ResolvedKeybinding } from 'vs/base/common/keyCodes';
@@ -176,18 +176,18 @@ export class ContextMenuController implements IEditorContribution {
getActions: () => actions,
getActionItem: (action) => {
getActionViewItem: (action) => {
const keybinding = this._keybindingFor(action);
if (keybinding) {
return new ActionItem(action, action, { label: true, keybinding: keybinding.getLabel(), isMenu: true });
return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel(), isMenu: true });
}
const customActionItem = <any>action;
if (typeof customActionItem.getActionItem === 'function') {
return customActionItem.getActionItem();
const customActionViewItem = <any>action;
if (typeof customActionViewItem.getActionViewItem === 'function') {
return customActionViewItem.getActionViewItem();
}
return new ActionItem(action, action, { icon: true, label: true, isMenu: true });
return new ActionViewItem(action, action, { icon: true, label: true, isMenu: true });
},
getKeyBinding: (action): ResolvedKeybinding | undefined => {
@@ -228,7 +228,7 @@ class ShowContextMenu extends EditorAction {
id: 'editor.action.showContextMenu',
label: nls.localize('action.showContextMenu.label', "Show Editor Context Menu"),
alias: 'Show Editor Context Menu',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.Shift | KeyCode.F10,
@@ -119,7 +119,7 @@ export class CursorUndo extends EditorAction {
id: 'cursorUndo',
label: nls.localize('cursor.undo', "Soft Undo"),
alias: 'Soft Undo',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_U,
+11 -11
View File
@@ -422,7 +422,7 @@ export class StartFindAction extends EditorAction {
id: FIND_IDS.StartFindAction,
label: nls.localize('startFindAction', "Find"),
alias: 'Find',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_F,
@@ -459,7 +459,7 @@ export class StartFindWithSelectionAction extends EditorAction {
id: FIND_IDS.StartFindWithSelection,
label: nls.localize('startFindWithSelectionAction', "Find With Selection"),
alias: 'Find With Selection',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: null,
primary: 0,
@@ -513,7 +513,7 @@ export class NextMatchFindAction extends MatchFindAction {
id: FIND_IDS.NextMatchFindAction,
label: nls.localize('findNextMatchAction', "Find Next"),
alias: 'Find Next',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: KeyCode.F3,
@@ -535,7 +535,7 @@ export class PreviousMatchFindAction extends MatchFindAction {
id: FIND_IDS.PreviousMatchFindAction,
label: nls.localize('findPreviousMatchAction', "Find Previous"),
alias: 'Find Previous',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: KeyMod.Shift | KeyCode.F3,
@@ -583,7 +583,7 @@ export class NextSelectionMatchFindAction extends SelectionMatchFindAction {
id: FIND_IDS.NextSelectionMatchFindAction,
label: nls.localize('nextSelectionMatchFindAction', "Find Next Selection"),
alias: 'Find Next Selection',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: KeyMod.CtrlCmd | KeyCode.F3,
@@ -604,7 +604,7 @@ export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction {
id: FIND_IDS.PreviousSelectionMatchFindAction,
label: nls.localize('previousSelectionMatchFindAction', "Find Previous Selection"),
alias: 'Find Previous Selection',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3,
@@ -625,7 +625,7 @@ export class StartFindReplaceAction extends EditorAction {
id: FIND_IDS.StartFindReplaceAction,
label: nls.localize('startReplace', "Replace"),
alias: 'Replace',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_H,
@@ -704,7 +704,7 @@ registerEditorCommand(new FindCommand({
registerEditorCommand(new FindCommand({
id: FIND_IDS.ToggleCaseSensitiveCommand,
precondition: null,
precondition: undefined,
handler: x => x.toggleCaseSensitive(),
kbOpts: {
weight: KeybindingWeight.EditorContrib + 5,
@@ -718,7 +718,7 @@ registerEditorCommand(new FindCommand({
registerEditorCommand(new FindCommand({
id: FIND_IDS.ToggleWholeWordCommand,
precondition: null,
precondition: undefined,
handler: x => x.toggleWholeWords(),
kbOpts: {
weight: KeybindingWeight.EditorContrib + 5,
@@ -732,7 +732,7 @@ registerEditorCommand(new FindCommand({
registerEditorCommand(new FindCommand({
id: FIND_IDS.ToggleRegexCommand,
precondition: null,
precondition: undefined,
handler: x => x.toggleRegex(),
kbOpts: {
weight: KeybindingWeight.EditorContrib + 5,
@@ -746,7 +746,7 @@ registerEditorCommand(new FindCommand({
registerEditorCommand(new FindCommand({
id: FIND_IDS.ToggleSearchScopeCommand,
precondition: null,
precondition: undefined,
handler: x => x.toggleSearchScope(),
kbOpts: {
weight: KeybindingWeight.EditorContrib + 5,
+10 -10
View File
@@ -503,7 +503,7 @@ class UnfoldAction extends FoldingAction<FoldingArguments> {
id: 'editor.unfold',
label: nls.localize('unfoldAction.label', "Unfold"),
alias: 'Unfold',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET,
@@ -567,7 +567,7 @@ class UnFoldRecursivelyAction extends FoldingAction<void> {
id: 'editor.unfoldRecursively',
label: nls.localize('unFoldRecursivelyAction.label', "Unfold Recursively"),
alias: 'Unfold Recursively',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET),
@@ -588,7 +588,7 @@ class FoldAction extends FoldingAction<FoldingArguments> {
id: 'editor.fold',
label: nls.localize('foldAction.label', "Fold"),
alias: 'Fold',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET,
@@ -652,7 +652,7 @@ class FoldRecursivelyAction extends FoldingAction<void> {
id: 'editor.foldRecursively',
label: nls.localize('foldRecursivelyAction.label', "Fold Recursively"),
alias: 'Fold Recursively',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET),
@@ -674,7 +674,7 @@ class FoldAllBlockCommentsAction extends FoldingAction<void> {
id: 'editor.foldAllBlockComments',
label: nls.localize('foldAllBlockComments.label', "Fold All Block Comments"),
alias: 'Fold All Block Comments',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_SLASH),
@@ -707,7 +707,7 @@ class FoldAllRegionsAction extends FoldingAction<void> {
id: 'editor.foldAllMarkerRegions',
label: nls.localize('foldAllMarkerRegions.label', "Fold All Regions"),
alias: 'Fold All Regions',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_8),
@@ -740,7 +740,7 @@ class UnfoldAllRegionsAction extends FoldingAction<void> {
id: 'editor.unfoldAllMarkerRegions',
label: nls.localize('unfoldAllMarkerRegions.label', "Unfold All Regions"),
alias: 'Unfold All Regions',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_9),
@@ -773,7 +773,7 @@ class FoldAllAction extends FoldingAction<void> {
id: 'editor.foldAll',
label: nls.localize('foldAllAction.label', "Fold All"),
alias: 'Fold All',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_0),
@@ -794,7 +794,7 @@ class UnfoldAllAction extends FoldingAction<void> {
id: 'editor.unfoldAll',
label: nls.localize('unfoldAllAction.label', "Unfold All"),
alias: 'Unfold All',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_J),
@@ -838,7 +838,7 @@ for (let i = 1; i <= 7; i++) {
id: FoldLevelAction.ID(i),
label: nls.localize('foldLevelAction.label', "Fold Level {0}", i),
alias: `Fold Level ${i}`,
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | (KeyCode.KEY_0 + i)),
+3 -3
View File
@@ -15,7 +15,7 @@ class EditorFontZoomIn extends EditorAction {
id: 'editor.action.fontZoomIn',
label: nls.localize('EditorFontZoomIn.label', "Editor Font Zoom In"),
alias: 'Editor Font Zoom In',
precondition: null
precondition: undefined
});
}
@@ -31,7 +31,7 @@ class EditorFontZoomOut extends EditorAction {
id: 'editor.action.fontZoomOut',
label: nls.localize('EditorFontZoomOut.label', "Editor Font Zoom Out"),
alias: 'Editor Font Zoom Out',
precondition: null
precondition: undefined
});
}
@@ -47,7 +47,7 @@ class EditorFontZoomReset extends EditorAction {
id: 'editor.action.fontZoomReset',
label: nls.localize('EditorFontZoomReset.label', "Editor Font Zoom Reset"),
alias: 'Editor Font Zoom Reset',
precondition: null
precondition: undefined
});
}
@@ -294,7 +294,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
private gotoDefinition(target: IMouseTarget, sideBySide: boolean): Promise<any> {
this.editor.setPosition(target.position!);
const action = new DefinitionAction(new DefinitionActionConfig(sideBySide, false, true, false), { alias: '', label: '', id: '', precondition: null });
const action = new DefinitionAction(new DefinitionActionConfig(sideBySide, false, true, false), { alias: '', label: '', id: '', precondition: undefined });
return this.editor.invokeWithinContext(accessor => action.run(accessor, this.editor));
}
+1 -1
View File
@@ -251,7 +251,7 @@ class ShowHoverAction extends EditorAction {
]
}, "Show Hover"),
alias: 'Show Hover',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I),
@@ -40,7 +40,6 @@ import { applyCodeAction, QuickFixAction } from 'vs/editor/contrib/codeAction/co
import { Action } from 'vs/base/common/actions';
import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger';
import { IModeService } from 'vs/editor/common/services/modeService';
import { withNullAsUndefined } from 'vs/base/common/types';
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
const $ = dom.$;
@@ -68,14 +67,13 @@ class ModesContentComputer implements IHoverComputer<HoverPart[]> {
private readonly _editor: ICodeEditor;
private _result: HoverPart[];
private _range: Range | null;
private _range?: Range;
constructor(
editor: ICodeEditor,
private readonly _markerDecorationsService: IMarkerDecorationsService
) {
this._editor = editor;
this._range = null;
}
setRange(range: Range): void {
@@ -183,7 +181,7 @@ class ModesContentComputer implements IHoverComputer<HoverPart[]> {
private _getLoadingMessage(): HoverPart {
return {
range: withNullAsUndefined(this._range),
range: this._range,
contents: [new MarkdownString().appendText(nls.localize('modesContentHover.loading', "Loading..."))]
};
}
@@ -253,7 +253,7 @@ export class IndentUsingTabs extends ChangeIndentationSizeAction {
id: IndentUsingTabs.ID,
label: nls.localize('indentUsingTabs', "Indent Using Tabs"),
alias: 'Indent Using Tabs',
precondition: null
precondition: undefined
});
}
}
@@ -267,7 +267,7 @@ export class IndentUsingSpaces extends ChangeIndentationSizeAction {
id: IndentUsingSpaces.ID,
label: nls.localize('indentUsingSpaces', "Indent Using Spaces"),
alias: 'Indent Using Spaces',
precondition: null
precondition: undefined
});
}
}
@@ -281,7 +281,7 @@ export class DetectIndentation extends EditorAction {
id: DetectIndentation.ID,
label: nls.localize('detectIndentation', "Detect Indentation from Content"),
alias: 'Detect Indentation from Content',
precondition: null
precondition: undefined
});
}
+1 -1
View File
@@ -410,7 +410,7 @@ class OpenLinkAction extends EditorAction {
id: 'editor.action.openLink',
label: nls.localize('label', "Open Link"),
alias: 'Open Link',
precondition: null
precondition: undefined
});
}
@@ -35,7 +35,7 @@ export class MessageController extends Disposable implements editorCommon.IEdito
private readonly _editor: ICodeEditor;
private readonly _visible: IContextKey<boolean>;
private _messageWidget: MessageWidget;
private _messageWidget?: MessageWidget;
private _messageListeners: IDisposable[] = [];
constructor(
@@ -96,7 +96,9 @@ export class MessageController extends Disposable implements editorCommon.IEdito
closeMessage(): void {
this._visible.reset();
this._messageListeners = dispose(this._messageListeners);
this._messageListeners.push(MessageWidget.fadeOut(this._messageWidget));
if (this._messageWidget) {
this._messageListeners.push(MessageWidget.fadeOut(this._messageWidget));
}
}
private _onDidAttemptReadOnlyEdit(): void {
@@ -34,7 +34,7 @@ export class InsertCursorAbove extends EditorAction {
id: 'editor.action.insertCursorAbove',
label: nls.localize('mutlicursor.insertAbove', "Add Cursor Above"),
alias: 'Add Cursor Above',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.UpArrow,
@@ -83,7 +83,7 @@ export class InsertCursorBelow extends EditorAction {
id: 'editor.action.insertCursorBelow',
label: nls.localize('mutlicursor.insertBelow', "Add Cursor Below"),
alias: 'Add Cursor Below',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.DownArrow,
@@ -132,7 +132,7 @@ class InsertCursorAtEndOfEachLineSelected extends EditorAction {
id: 'editor.action.insertCursorAtEndOfEachLineSelected',
label: nls.localize('mutlicursor.insertAtEndOfEachLineSelected', "Add Cursors to Line Ends"),
alias: 'Add Cursors to Line Ends',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_I,
@@ -184,7 +184,7 @@ class InsertCursorAtEndOfLineSelected extends EditorAction {
id: 'editor.action.addCursorsToBottom',
label: nls.localize('mutlicursor.addCursorsToBottom', "Add Cursors To Bottom"),
alias: 'Add Cursors To Bottom',
precondition: null
precondition: undefined
});
}
@@ -214,7 +214,7 @@ class InsertCursorAtTopOfLineSelected extends EditorAction {
id: 'editor.action.addCursorsToTop',
label: nls.localize('mutlicursor.addCursorsToTop', "Add Cursors To Top"),
alias: 'Add Cursors To Top',
precondition: null
precondition: undefined
});
}
@@ -650,7 +650,7 @@ export class AddSelectionToNextFindMatchAction extends MultiCursorSelectionContr
id: 'editor.action.addSelectionToNextFindMatch',
label: nls.localize('addSelectionToNextFindMatch', "Add Selection To Next Find Match"),
alias: 'Add Selection To Next Find Match',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_D,
@@ -675,7 +675,7 @@ export class AddSelectionToPreviousFindMatchAction extends MultiCursorSelectionC
id: 'editor.action.addSelectionToPreviousFindMatch',
label: nls.localize('addSelectionToPreviousFindMatch', "Add Selection To Previous Find Match"),
alias: 'Add Selection To Previous Find Match',
precondition: null,
precondition: undefined,
menubarOpts: {
menuId: MenuId.MenubarSelectionMenu,
group: '3_multi',
@@ -695,7 +695,7 @@ export class MoveSelectionToNextFindMatchAction extends MultiCursorSelectionCont
id: 'editor.action.moveSelectionToNextFindMatch',
label: nls.localize('moveSelectionToNextFindMatch', "Move Last Selection To Next Find Match"),
alias: 'Move Last Selection To Next Find Match',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_D),
@@ -714,7 +714,7 @@ export class MoveSelectionToPreviousFindMatchAction extends MultiCursorSelection
id: 'editor.action.moveSelectionToPreviousFindMatch',
label: nls.localize('moveSelectionToPreviousFindMatch', "Move Last Selection To Previous Find Match"),
alias: 'Move Last Selection To Previous Find Match',
precondition: null
precondition: undefined
});
}
protected _run(multiCursorController: MultiCursorSelectionController, findController: CommonFindController): void {
@@ -728,7 +728,7 @@ export class SelectHighlightsAction extends MultiCursorSelectionControllerAction
id: 'editor.action.selectHighlights',
label: nls.localize('selectAllOccurrencesOfFindMatch', "Select All Occurrences of Find Match"),
alias: 'Select All Occurrences of Find Match',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_L,
@@ -161,7 +161,7 @@ class GrowSelectionAction extends AbstractSmartSelect {
id: 'editor.action.smartSelect.expand',
label: nls.localize('smartSelect.expand', "Expand Selection"),
alias: 'Expand Selection',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.RightArrow,
@@ -187,7 +187,7 @@ class ShrinkSelectionAction extends AbstractSmartSelect {
id: 'editor.action.smartSelect.shrink',
label: nls.localize('smartSelect.shrink', "Shrink Selection"),
alias: 'Shrink Selection',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.LeftArrow,
@@ -20,7 +20,7 @@ export class ToggleTabFocusModeAction extends EditorAction {
id: ToggleTabFocusModeAction.ID,
label: nls.localize({ key: 'toggle.tabMovesFocus', comment: ['Turn on/off use of tab key for moving focus around VS Code'] }, "Toggle Tab Key Moves Focus"),
alias: 'Toggle Tab Key Moves Focus',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_M,
@@ -14,7 +14,7 @@ class ForceRetokenizeAction extends EditorAction {
id: 'editor.action.forceRetokenize',
label: nls.localize('forceRetokenize', "Developer: Force Retokenize"),
alias: 'Developer: Force Retokenize',
precondition: null
precondition: undefined
});
}
@@ -98,7 +98,7 @@ export class CursorWordStartLeft extends WordLeftCommand {
inSelectionMode: false,
wordNavigationType: WordNavigationType.WordStart,
id: 'cursorWordStartLeft',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.LeftArrow,
@@ -115,7 +115,7 @@ export class CursorWordEndLeft extends WordLeftCommand {
inSelectionMode: false,
wordNavigationType: WordNavigationType.WordEnd,
id: 'cursorWordEndLeft',
precondition: null
precondition: undefined
});
}
}
@@ -126,7 +126,7 @@ export class CursorWordLeft extends WordLeftCommand {
inSelectionMode: false,
wordNavigationType: WordNavigationType.WordStartFast,
id: 'cursorWordLeft',
precondition: null
precondition: undefined
});
}
}
@@ -137,7 +137,7 @@ export class CursorWordStartLeftSelect extends WordLeftCommand {
inSelectionMode: true,
wordNavigationType: WordNavigationType.WordStart,
id: 'cursorWordStartLeftSelect',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow,
@@ -154,7 +154,7 @@ export class CursorWordEndLeftSelect extends WordLeftCommand {
inSelectionMode: true,
wordNavigationType: WordNavigationType.WordEnd,
id: 'cursorWordEndLeftSelect',
precondition: null
precondition: undefined
});
}
}
@@ -165,7 +165,7 @@ export class CursorWordLeftSelect extends WordLeftCommand {
inSelectionMode: true,
wordNavigationType: WordNavigationType.WordStart,
id: 'cursorWordLeftSelect',
precondition: null
precondition: undefined
});
}
}
@@ -176,7 +176,7 @@ export class CursorWordStartRight extends WordRightCommand {
inSelectionMode: false,
wordNavigationType: WordNavigationType.WordStart,
id: 'cursorWordStartRight',
precondition: null
precondition: undefined
});
}
}
@@ -187,7 +187,7 @@ export class CursorWordEndRight extends WordRightCommand {
inSelectionMode: false,
wordNavigationType: WordNavigationType.WordEnd,
id: 'cursorWordEndRight',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.RightArrow,
@@ -204,7 +204,7 @@ export class CursorWordRight extends WordRightCommand {
inSelectionMode: false,
wordNavigationType: WordNavigationType.WordEnd,
id: 'cursorWordRight',
precondition: null
precondition: undefined
});
}
}
@@ -215,7 +215,7 @@ export class CursorWordStartRightSelect extends WordRightCommand {
inSelectionMode: true,
wordNavigationType: WordNavigationType.WordStart,
id: 'cursorWordStartRightSelect',
precondition: null
precondition: undefined
});
}
}
@@ -226,7 +226,7 @@ export class CursorWordEndRightSelect extends WordRightCommand {
inSelectionMode: true,
wordNavigationType: WordNavigationType.WordEnd,
id: 'cursorWordEndRightSelect',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow,
@@ -243,7 +243,7 @@ export class CursorWordRightSelect extends WordRightCommand {
inSelectionMode: true,
wordNavigationType: WordNavigationType.WordEnd,
id: 'cursorWordRightSelect',
precondition: null
precondition: undefined
});
}
}
@@ -79,7 +79,7 @@ export class CursorWordPartLeft extends WordPartLeftCommand {
inSelectionMode: false,
wordNavigationType: WordNavigationType.WordStart,
id: 'cursorWordPartLeft',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: 0,
@@ -98,7 +98,7 @@ export class CursorWordPartLeftSelect extends WordPartLeftCommand {
inSelectionMode: true,
wordNavigationType: WordNavigationType.WordStart,
id: 'cursorWordPartLeftSelect',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: 0,
@@ -122,7 +122,7 @@ export class CursorWordPartRight extends WordPartRightCommand {
inSelectionMode: false,
wordNavigationType: WordNavigationType.WordEnd,
id: 'cursorWordPartRight',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: 0,
@@ -138,7 +138,7 @@ export class CursorWordPartRightSelect extends WordPartRightCommand {
inSelectionMode: true,
wordNavigationType: WordNavigationType.WordEnd,
id: 'cursorWordPartRightSelect',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: 0,
@@ -330,7 +330,7 @@ class ShowAccessibilityHelpAction extends EditorAction {
id: 'editor.action.showAccessibilityHelp',
label: AccessibilityHelpNLS.showAccessibilityHelpAction,
alias: 'Show Accessibility Help',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: (browser.isIE ? KeyMod.CtrlCmd | KeyCode.F1 : KeyMod.Alt | KeyCode.F1),
@@ -84,7 +84,7 @@ class InspectTokens extends EditorAction {
id: 'editor.action.inspectTokens',
label: InspectTokensNLS.inspectTokensAction,
alias: 'Developer: Inspect Tokens',
precondition: null
precondition: undefined
});
}
@@ -149,7 +149,7 @@ export class GotoLineAction extends BaseEditorQuickOpenAction {
id: 'editor.action.gotoLine',
label: GoToLineNLS.gotoLineActionLabel,
alias: 'Go to Line...',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_G,
@@ -82,7 +82,7 @@ export class QuickCommandAction extends BaseEditorQuickOpenAction {
id: 'editor.action.quickCommand',
label: QuickCommandNLS.quickCommandActionLabel,
alias: 'Command Palette',
precondition: null,
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: (browser.isIE ? KeyMod.Alt | KeyCode.F1 : KeyCode.F1),
@@ -26,12 +26,12 @@ let SCOPE_PREFIX = ':';
export class SymbolEntry extends QuickOpenEntryGroup {
private readonly name: string;
private readonly type: string;
private readonly description: string | null;
private readonly description: string | undefined;
private readonly range: Range;
private readonly editor: ICodeEditor;
private readonly decorator: IDecorator;
constructor(name: string, type: string, description: string | null, range: Range, highlights: IHighlight[], editor: ICodeEditor, decorator: IDecorator) {
constructor(name: string, type: string, description: string | undefined, range: Range, highlights: IHighlight[], editor: ICodeEditor, decorator: IDecorator) {
super();
this.name = name;
@@ -55,7 +55,7 @@ export class SymbolEntry extends QuickOpenEntryGroup {
return this.type;
}
public getDescription(): string | null {
public getDescription(): string | undefined {
return this.description;
}
@@ -169,7 +169,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
});
}
private symbolEntry(name: string, type: string, description: string | null, range: IRange, highlights: IHighlight[], editor: ICodeEditor, decorator: IDecorator): SymbolEntry {
private symbolEntry(name: string, type: string, description: string | undefined, range: IRange, highlights: IHighlight[], editor: ICodeEditor, decorator: IDecorator): SymbolEntry {
return new SymbolEntry(name, type, description, Range.lift(range), highlights, editor, decorator);
}
@@ -192,7 +192,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
if (highlights) {
// Show parent scope as description
let description: string | null = null;
let description: string | undefined = undefined;
if (element.containerName) {
description = element.containerName;
}
@@ -19,7 +19,7 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
import { IPosition, Position as Pos } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ITextModel } from 'vs/editor/common/model';
import { ITextModel, ITextSnapshot } from 'vs/editor/common/model';
import { TextEdit, WorkspaceEdit, isResourceTextEdit } from 'vs/editor/common/modes';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IResolvedTextEditorModel, ITextModelContentProvider, ITextModelService } from 'vs/editor/common/services/resolverService';
@@ -67,6 +67,10 @@ export class SimpleModel implements IResolvedTextEditorModel {
return this.model;
}
public createSnapshot(): ITextSnapshot {
return this.model.createSnapshot();
}
public isReadonly(): boolean {
return false;
}
@@ -348,7 +352,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
if (!keybinding) {
// This might be a removal keybinding item in user settings => accept it
result[resultLen++] = new ResolvedKeybindingItem(null, item.command, item.commandArgs, when, isDefault);
result[resultLen++] = new ResolvedKeybindingItem(undefined, item.command, item.commandArgs, when, isDefault);
} else {
const resolvedKeybindings = this.resolveKeybinding(keybinding);
for (const resolvedKeybinding of resolvedKeybindings) {
@@ -17,7 +17,7 @@ class ToggleHighContrast extends EditorAction {
id: 'editor.action.toggleHighContrast',
label: ToggleHighContrastNLS.toggleHighContrast,
alias: 'Toggle High Contrast Theme',
precondition: null
precondition: undefined
});
this._originalThemeName = null;
}
@@ -5,7 +5,7 @@
import { addClasses, createCSSRule, removeClasses } from 'vs/base/browser/dom';
import { domEvent } from 'vs/base/browser/event';
import { ActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { ActionViewItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IAction } from 'vs/base/common/actions';
import { Emitter } from 'vs/base/common/event';
import { IdGenerator } from 'vs/base/common/idGenerator';
@@ -114,16 +114,16 @@ export function fillInActions(groups: [string, Array<MenuItemAction | SubmenuIte
}
export function createActionItem(action: IAction, keybindingService: IKeybindingService, notificationService: INotificationService, contextMenuService: IContextMenuService): ActionItem | undefined {
export function createActionViewItem(action: IAction, keybindingService: IKeybindingService, notificationService: INotificationService, contextMenuService: IContextMenuService): ActionViewItem | undefined {
if (action instanceof MenuItemAction) {
return new MenuItemActionItem(action, keybindingService, notificationService, contextMenuService);
return new MenuEntryActionViewItem(action, keybindingService, notificationService, contextMenuService);
}
return undefined;
}
const ids = new IdGenerator('menu-item-action-item-icon-');
export class MenuItemActionItem extends ActionItem {
export class MenuEntryActionViewItem extends ActionViewItem {
static readonly ICON_PATH_TO_CSS_RULES: Map<string /* path*/, string /* CSS rule */> = new Map<string, string>();
@@ -231,13 +231,13 @@ export class MenuItemActionItem extends ActionItem {
const iconPathMapKey = item.iconLocation.dark.toString();
if (MenuItemActionItem.ICON_PATH_TO_CSS_RULES.has(iconPathMapKey)) {
iconClass = MenuItemActionItem.ICON_PATH_TO_CSS_RULES.get(iconPathMapKey)!;
if (MenuEntryActionViewItem.ICON_PATH_TO_CSS_RULES.has(iconPathMapKey)) {
iconClass = MenuEntryActionViewItem.ICON_PATH_TO_CSS_RULES.get(iconPathMapKey)!;
} else {
iconClass = ids.nextId();
createCSSRule(`.icon.${iconClass}`, `background-image: url("${(item.iconLocation.light || item.iconLocation.dark).toString()}")`);
createCSSRule(`.vs-dark .icon.${iconClass}, .hc-black .icon.${iconClass}`, `background-image: url("${item.iconLocation.dark.toString()}")`);
MenuItemActionItem.ICON_PATH_TO_CSS_RULES.set(iconPathMapKey, iconClass);
MenuEntryActionViewItem.ICON_PATH_TO_CSS_RULES.set(iconPathMapKey, iconClass);
}
addClasses(this.label, 'icon', iconClass);
@@ -255,10 +255,10 @@ export class MenuItemActionItem extends ActionItem {
}
}
// Need to subclass MenuItemActionItem in order to respect
// Need to subclass MenuEntryActionViewItem in order to respect
// the action context coming from any action bar, without breaking
// existing users
export class ContextAwareMenuItemActionItem extends MenuItemActionItem {
export class ContextAwareMenuEntryActionViewItem extends MenuEntryActionViewItem {
onClick(event: MouseEvent): void {
event.preventDefault();
@@ -273,7 +273,7 @@ export class ContextAwareMenuItemActionItem extends MenuItemActionItem {
// Always show label for action items, instead of whether they don't have
// an icon/CSS class. Useful for some toolbar scenarios in particular with
// contributed actions from other extensions
export class LabeledMenuItemActionItem extends MenuItemActionItem {
export class LabeledMenuItemActionItem extends MenuEntryActionViewItem {
private _labeledItemClassDispose: IDisposable;
constructor(
@@ -301,13 +301,13 @@ export class LabeledMenuItemActionItem extends MenuItemActionItem {
const iconPathMapKey = item.iconLocation.dark.toString();
if (MenuItemActionItem.ICON_PATH_TO_CSS_RULES.has(iconPathMapKey)) {
iconClass = MenuItemActionItem.ICON_PATH_TO_CSS_RULES.get(iconPathMapKey);
if (MenuEntryActionViewItem.ICON_PATH_TO_CSS_RULES.has(iconPathMapKey)) {
iconClass = MenuEntryActionViewItem.ICON_PATH_TO_CSS_RULES.get(iconPathMapKey);
} else {
iconClass = ids.nextId();
createCSSRule(`.icon.${iconClass}`, `background-image: url("${(item.iconLocation.light || item.iconLocation.dark).toString()}")`);
createCSSRule(`.vs-dark .icon.${iconClass}, .hc-black .icon.${iconClass}`, `background-image: url("${item.iconLocation.dark.toString()}")`);
MenuItemActionItem.ICON_PATH_TO_CSS_RULES.set(iconPathMapKey, iconClass);
MenuEntryActionViewItem.ICON_PATH_TO_CSS_RULES.set(iconPathMapKey, iconClass);
}
addClasses(this.label, 'icon', iconClass, this._defaultCSSClassToAdd);
+4 -7
View File
@@ -18,21 +18,18 @@ export interface ILocalizedString {
original: string;
}
export interface IBaseCommandAction {
export interface ICommandAction {
id: string;
title: string | ILocalizedString;
category?: string | ILocalizedString;
}
export interface ICommandAction extends IBaseCommandAction {
iconLocation?: { dark: URI; light?: URI; };
precondition?: ContextKeyExpr;
toggled?: ContextKeyExpr;
}
export interface ISerializableCommandAction extends IBaseCommandAction {
iconLocation?: { dark: UriComponents; light?: UriComponents; };
}
type Serialized<T> = { [K in keyof T]: T[K] extends URI ? UriComponents : Serialized<T[K]> };
export type ISerializableCommandAction = Serialized<ICommandAction>;
export interface IMenuItem {
command: ICommandAction;
@@ -73,7 +73,7 @@ export class ContextMenuHandler {
actionRunner.onDidBeforeRun(this.onActionRun, this, menuDisposables);
actionRunner.onDidRun(this.onDidActionRun, this, menuDisposables);
menu = new Menu(container, actions, {
actionItemProvider: delegate.getActionItem,
actionViewItemProvider: delegate.getActionViewItem,
context: delegate.getActionsContext ? delegate.getActionsContext() : null,
actionRunner,
getKeyBinding: delegate.getKeyBinding ? delegate.getKeyBinding : action => this.keybindingService.lookupKeybinding(action.id)
@@ -186,8 +186,8 @@ class WindowDriver implements IWindowDriver {
const lines: string[] = [];
for (let i = 0; i < xterm._core.buffer.lines.length; i++) {
lines.push(xterm._core.buffer.translateBufferLineToString(i, true));
for (let i = 0; i < xterm.buffer.length; i++) {
lines.push(xterm.buffer.getLine(i)!.translateToString(true));
}
return lines;
+7 -1
View File
@@ -63,7 +63,7 @@ export interface IBaseResourceInput {
export interface IResourceInput extends IBaseResourceInput {
/**
* The resource URL of the resource to open.
* The resource URI of the resource to open.
*/
resource: URI;
@@ -71,6 +71,12 @@ export interface IResourceInput extends IBaseResourceInput {
* The encoding of the text input if known.
*/
readonly encoding?: string;
/**
* The identifier of the language mode of the text input
* if known to use when displaying the contents.
*/
readonly mode?: string;
}
export interface IEditorOptions {
@@ -69,7 +69,6 @@ export interface ParsedArgs {
'driver'?: string;
'driver-verbose'?: boolean;
remote?: string;
'nodeless'?: boolean; // TODO@ben revisit electron5 nodeless support
// {{SQL CARBON EDIT}}
aad?: boolean;
database?: string;
-2
View File
@@ -95,8 +95,6 @@ export const options: Option[] = [
{ id: 'trace-category-filter', type: 'string' },
{ id: 'trace-options', type: 'string' },
{ id: 'prof-code-loading', type: 'boolean' },
{ id: 'nodeless', type: 'boolean' }, // TODO@ben revisit electron5 nodeless support
// {{SQL CARBON EDIT}}
{ id: 'database', type: 'string', alias: 'D' },
{ id: 'server', type: 'string', alias: 'S' },

Some files were not shown because too many files have changed in this diff Show More