Merge from vscode 777931080477e28b7c27e8f7d4b0d69897945946 (#9220)

This commit is contained in:
Anthony Dresser
2020-02-19 22:27:53 -08:00
committed by GitHub
parent ab6fb810f8
commit 0cec223301
115 changed files with 1431 additions and 1133 deletions

View File

@@ -736,6 +736,35 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.toggleSelection',
weight: KeybindingWeight.WorkbenchContrib,
when: WorkbenchListFocusContextKey,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter,
handler: (accessor) => {
const widget = accessor.get(IListService).lastFocusedList;
if (!widget || isLegacyTree(widget)) {
return;
}
const focus = widget.getFocus();
if (focus.length === 0) {
return;
}
const selection = widget.getSelection();
const index = selection.indexOf(focus[0]);
if (index > -1) {
widget.setSelection([...selection.slice(0, index), ...selection.slice(index + 1)]);
} else {
widget.setSelection([...selection, focus[0]]);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.toggleExpand',
weight: KeybindingWeight.WorkbenchContrib,

View File

@@ -28,7 +28,6 @@ import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/commo
import { withNullAsUndefined } from 'vs/base/common/types';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { isStandalone } from 'vs/base/browser/browser';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
export interface IDraggedResource {
@@ -343,7 +342,6 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources:
// Editors: enables cross window DND of tabs into the editor area
const textFileService = accessor.get(ITextFileService);
const editorService = accessor.get(IEditorService);
const modelService = accessor.get(IModelService);
const draggedEditors: ISerializedDraggedEditor[] = [];
files.forEach(file => {
@@ -374,11 +372,8 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources:
// If the resource is dirty or untitled, send over its content
// to restore dirty state. Get that from the text model directly
let content: string | undefined = undefined;
if (textFileService.isDirty(file.resource)) {
const textModel = modelService.getModel(file.resource);
if (textModel) {
content = textModel.getValue();
}
if (model?.isDirty()) {
content = model.textEditorModel.getValue();
}
// Add as dragged editor

View File

@@ -148,8 +148,8 @@ export class ResourceLabels extends Disposable {
}));
// notify when untitled labels change
this.textFileService.untitled.onDidChangeLabel(resource => {
this._widgets.forEach(widget => widget.notifyUntitledLabelChange(resource));
this.textFileService.untitled.onDidChangeLabel(model => {
this._widgets.forEach(widget => widget.notifyUntitledLabelChange(model.resource));
});
}

View File

@@ -122,8 +122,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private workbenchGrid!: SerializableGrid<ISerializableView>;
private editorWidgetSet = new Set<IEditor>();
private disposed: boolean | undefined;
private titleBarPartView!: ISerializableView;
@@ -198,7 +196,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
wasSideBarVisible: false,
wasPanelVisible: false,
transitionDisposables: new DisposableStore(),
setNotificationsFilter: false
setNotificationsFilter: false,
editorWidgetSet: new Set<IEditor>()
},
};
@@ -708,15 +707,21 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
editor.updateOptions({ lineNumbers });
};
const editorWidgetSet = this.state.zenMode.editorWidgetSet;
if (!lineNumbers) {
// Reset line numbers on all editors visible and non-visible
for (const editor of this.editorWidgetSet) {
for (const editor of editorWidgetSet) {
setEditorLineNumbers(editor);
}
this.editorWidgetSet.clear();
editorWidgetSet.clear();
} else {
this.editorService.visibleTextEditorWidgets.forEach(editor => {
this.editorWidgetSet.add(editor);
if (!editorWidgetSet.has(editor)) {
editorWidgetSet.add(editor);
this.state.zenMode.transitionDisposables.add(editor.onDidDispose(() => {
editorWidgetSet.delete(editor);
}));
}
setEditorLineNumbers(editor);
});
}

View File

@@ -470,7 +470,7 @@ export class BreadcrumbsControl {
this._ckBreadcrumbsActive.set(value);
}
private _revealInEditor(event: IBreadcrumbsItemEvent, element: any, group: SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE | undefined, pinned: boolean = false): void {
private _revealInEditor(event: IBreadcrumbsItemEvent, element: BreadcrumbElement, group: SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE | undefined, pinned: boolean = false): void {
if (element instanceof FileElement) {
if (element.kind === FileKind.FILE) {
// open file in any editor

View File

@@ -71,10 +71,8 @@ export class BaseSplitEditorAction extends Action {
}));
}
run(context?: IEditorIdentifier): Promise<any> {
async run(context?: IEditorIdentifier): Promise<any> {
splitEditor(this.editorGroupService, this.direction, context);
return Promise.resolve(true);
}
}
@@ -183,7 +181,7 @@ export class JoinTwoGroupsAction extends Action {
super(id, label);
}
run(context?: IEditorIdentifier): Promise<any> {
async run(context?: IEditorIdentifier): Promise<any> {
let sourceGroup: IEditorGroup | undefined;
if (context && typeof context.groupId === 'number') {
sourceGroup = this.editorGroupService.getGroup(context.groupId);
@@ -198,12 +196,10 @@ export class JoinTwoGroupsAction extends Action {
if (targetGroup && sourceGroup !== targetGroup) {
this.editorGroupService.mergeGroup(sourceGroup, targetGroup);
return Promise.resolve(true);
break;
}
}
}
return Promise.resolve(true);
}
}
@@ -220,10 +216,8 @@ export class JoinAllGroupsAction extends Action {
super(id, label);
}
run(context?: IEditorIdentifier): Promise<any> {
async run(context?: IEditorIdentifier): Promise<any> {
mergeAllGroups(this.editorGroupService);
return Promise.resolve(true);
}
}
@@ -240,11 +234,9 @@ export class NavigateBetweenGroupsAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
const nextGroup = this.editorGroupService.findGroup({ location: GroupLocation.NEXT }, this.editorGroupService.activeGroup, true);
nextGroup.focus();
return Promise.resolve(true);
}
}
@@ -261,10 +253,8 @@ export class FocusActiveGroupAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.editorGroupService.activeGroup.focus();
return Promise.resolve(true);
}
}
@@ -279,13 +269,11 @@ export abstract class BaseFocusGroupAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
const group = this.editorGroupService.findGroup(this.scope, this.editorGroupService.activeGroup, true);
if (group) {
group.focus();
}
return Promise.resolve(true);
}
}
@@ -421,7 +409,7 @@ export class OpenToSideFromQuickOpenAction extends Action {
this.class = (preferredDirection === GroupDirection.RIGHT) ? 'codicon-split-horizontal' : 'codicon-split-vertical';
}
run(context: any): Promise<any> {
async run(context: any): Promise<any> {
const entry = toEditorQuickOpenEntry(context);
if (entry) {
const input = entry.getInput();
@@ -436,8 +424,6 @@ export class OpenToSideFromQuickOpenAction extends Action {
return this.editorService.openEditor(resourceInput, SIDE_GROUP);
}
}
return Promise.resolve(false);
}
}
@@ -490,7 +476,7 @@ export class CloseOneEditorAction extends Action {
super(id, label, 'codicon-close');
}
run(context?: IEditorCommandsContext): Promise<any> {
async run(context?: IEditorCommandsContext): Promise<any> {
let group: IEditorGroup | undefined;
let editorIndex: number | undefined;
if (context) {
@@ -517,8 +503,6 @@ export class CloseOneEditorAction extends Action {
if (group.activeEditor) {
return group.closeEditor(group.activeEditor);
}
return Promise.resolve(false);
}
}
@@ -554,8 +538,6 @@ export class RevertAndCloseEditorAction extends Action {
group.closeEditor(editor);
}
return true;
}
}
@@ -573,13 +555,11 @@ export class CloseLeftEditorsInGroupAction extends Action {
super(id, label);
}
run(context?: IEditorIdentifier): Promise<any> {
async run(context?: IEditorIdentifier): Promise<any> {
const { group, editor } = getTarget(this.editorService, this.editorGroupService, context);
if (group && editor) {
return group.closeEditors({ direction: CloseDirection.LEFT, except: editor });
}
return Promise.resolve(false);
}
}
@@ -736,9 +716,9 @@ export class CloseEditorsInOtherGroupsAction extends Action {
run(context?: IEditorIdentifier): Promise<any> {
const groupToSkip = context ? this.editorGroupService.getGroup(context.groupId) : this.editorGroupService.activeGroup;
return Promise.all(this.editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE).map(g => {
return Promise.all(this.editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE).map(async g => {
if (groupToSkip && g.id === groupToSkip.id) {
return Promise.resolve();
return;
}
return g.closeAllEditors();
@@ -760,13 +740,11 @@ export class CloseEditorInAllGroupsAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
const activeEditor = this.editorService.activeEditor;
if (activeEditor) {
return Promise.all(this.editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE).map(g => g.closeEditor(activeEditor)));
}
return Promise.resolve();
}
}
@@ -781,7 +759,7 @@ export class BaseMoveGroupAction extends Action {
super(id, label);
}
run(context?: IEditorIdentifier): Promise<any> {
async run(context?: IEditorIdentifier): Promise<any> {
let sourceGroup: IEditorGroup | undefined;
if (context && typeof context.groupId === 'number') {
sourceGroup = this.editorGroupService.getGroup(context.groupId);
@@ -795,8 +773,6 @@ export class BaseMoveGroupAction extends Action {
this.editorGroupService.moveGroup(sourceGroup, targetGroup, this.direction);
}
}
return Promise.resolve(true);
}
private findTargetGroup(sourceGroup: IEditorGroup): IEditorGroup | undefined {
@@ -892,10 +868,8 @@ export class MinimizeOtherGroupsAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.editorGroupService.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
return Promise.resolve(false);
}
}
@@ -908,10 +882,8 @@ export class ResetGroupSizesAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.editorGroupService.arrangeGroups(GroupsArrangement.EVEN);
return Promise.resolve(false);
}
}
@@ -924,10 +896,8 @@ export class ToggleGroupSizesAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.editorGroupService.arrangeGroups(GroupsArrangement.TOGGLE);
return Promise.resolve(false);
}
}
@@ -946,13 +916,11 @@ export class MaximizeGroupAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
if (this.editorService.activeEditor) {
this.editorGroupService.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
this.layoutService.setSideBarHidden(true);
}
return Promise.resolve(false);
}
}
@@ -967,23 +935,21 @@ export abstract class BaseNavigateEditorAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
const result = this.navigate();
if (!result) {
return Promise.resolve(false);
return;
}
const { groupId, editor } = result;
if (!editor) {
return Promise.resolve(false);
return;
}
const group = this.editorGroupService.getGroup(groupId);
if (group) {
return group.openEditor(editor);
}
return Promise.resolve();
}
protected abstract navigate(): IEditorIdentifier | undefined;
@@ -1158,10 +1124,8 @@ export class NavigateForwardAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.forward();
return Promise.resolve();
}
}
@@ -1174,10 +1138,8 @@ export class NavigateBackwardsAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.back();
return Promise.resolve();
}
}
@@ -1190,10 +1152,8 @@ export class NavigateToLastEditLocationAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.openLastEditLocation();
return Promise.resolve();
}
}
@@ -1206,10 +1166,8 @@ export class NavigateLastAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.last();
return Promise.resolve();
}
}
@@ -1226,10 +1184,8 @@ export class ReopenClosedEditorAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.reopenLastClosedEditor();
return Promise.resolve(false);
}
}
@@ -1247,15 +1203,13 @@ export class ClearRecentFilesAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
// Clear global recently opened
this.workspacesService.clearRecentlyOpened();
// Clear workspace specific recently opened
this.historyService.clearRecentlyOpened();
return Promise.resolve(false);
}
}
@@ -1313,12 +1267,10 @@ export class BaseQuickOpenEditorAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
const keybindings = this.keybindingService.lookupKeybindings(this.id);
this.quickOpenService.show(this.prefix, { quickNavigateConfiguration: { keybindings } });
return Promise.resolve(true);
}
}
@@ -1396,12 +1348,10 @@ export class QuickOpenPreviousEditorFromHistoryAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
const keybindings = this.keybindingService.lookupKeybindings(this.id);
this.quickOpenService.show(undefined, { quickNavigateConfiguration: { keybindings } });
return Promise.resolve(true);
}
}
@@ -1418,10 +1368,8 @@ export class OpenNextRecentlyUsedEditorAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.openNextRecentlyUsedEditor();
return Promise.resolve();
}
}
@@ -1438,10 +1386,8 @@ export class OpenPreviousRecentlyUsedEditorAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.openPreviouslyUsedEditor();
return Promise.resolve();
}
}
@@ -1459,10 +1405,8 @@ export class OpenNextRecentlyUsedEditorInGroupAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.openNextRecentlyUsedEditor(this.editorGroupsService.activeGroup.id);
return Promise.resolve();
}
}
@@ -1480,10 +1424,8 @@ export class OpenPreviousRecentlyUsedEditorInGroupAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.historyService.openPreviouslyUsedEditor(this.editorGroupsService.activeGroup.id);
return Promise.resolve();
}
}
@@ -1500,12 +1442,10 @@ export class ClearEditorHistoryAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
// Editor history
this.historyService.clear();
return Promise.resolve(true);
}
}
@@ -1772,10 +1712,8 @@ export class BaseCreateEditorGroupAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
this.editorGroupService.addGroup(this.editorGroupService.activeGroup, this.direction, { activate: true });
return Promise.resolve(true);
}
}

View File

@@ -317,8 +317,8 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
private registerListeners(): void {
this._register(this.editorService.onDidActiveEditorChange(() => this.updateStatusBar()));
this._register(this.textFileService.untitled.onDidChangeEncoding(r => this.onResourceEncodingChange(r)));
this._register(this.textFileService.files.onDidChangeEncoding(m => this.onResourceEncodingChange((m.resource))));
this._register(this.textFileService.untitled.onDidChangeEncoding(model => this.onResourceEncodingChange(model.resource)));
this._register(this.textFileService.files.onDidChangeEncoding(model => this.onResourceEncodingChange((model.resource))));
this._register(TabFocus.onDidChangeTabFocus(e => this.onTabFocusModeChange()));
}

View File

@@ -30,7 +30,6 @@ import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/commo
import { CancellationToken } from 'vs/base/common/cancellation';
import { EditorMemento } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorActivation, IEditorOptions } from 'vs/platform/editor/common/editor';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
/**
* The text editor that leverages the diff text editor for the editing experience.
@@ -51,8 +50,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IEditorService editorService: IEditorService,
@IThemeService themeService: IThemeService,
@IEditorGroupsService editorGroupService: IEditorGroupsService,
@IClipboardService private clipboardService: IClipboardService
@IEditorGroupsService editorGroupService: IEditorGroupsService
) {
super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, editorService, editorGroupService);
}
@@ -75,10 +73,8 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
}
createEditorControl(parent: HTMLElement, configuration: ICodeEditorOptions): IDiffEditor {
if (this.reverseColor) { // {{SQL CARBON EDIT}}
(configuration as IDiffEditorOptions).reverse = true;
}
return this.instantiationService.createInstance(DiffEditorWidget as any, parent, configuration, this.clipboardService); // {{SQL CARBON EDIT}} strict-null-check...i guess?
if (this.reverseColor) { (configuration as IDiffEditorOptions).reverse = true; } // {{SQL CARBON EDIT}}
return this.instantiationService.createInstance(DiffEditorWidget, parent, configuration);
}
async setInput(input: EditorInput, options: EditorOptions | undefined, token: CancellationToken): Promise<void> {

View File

@@ -12,7 +12,7 @@ import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND, SIDE_BAR_SECTION_HEADER_FOREGROUND,
import { append, $, trackFocus, toggleClass, EventType, isAncestor, Dimension, addDisposableListener, removeClass, addClass } from 'vs/base/browser/dom';
import { IDisposable, combinedDisposable, dispose, toDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { firstIndex } from 'vs/base/common/arrays';
import { IAction, IActionRunner, ActionRunner } from 'vs/base/common/actions';
import { IAction } from 'vs/base/common/actions';
import { IActionViewItem, ActionsOrientation, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { Registry } from 'vs/platform/registry/common/platform';
import { prepareActions } from 'vs/workbench/browser/actions';
@@ -51,7 +51,6 @@ export interface IPaneColors extends IColorMapping {
}
export interface IViewPaneOptions extends IPaneOptions {
actionRunner?: IActionRunner;
id: string;
title: string;
showActionsAlways?: boolean;
@@ -169,7 +168,6 @@ export abstract class ViewPane extends Pane implements IView {
private readonly menuActions: ViewMenuActions;
protected actionRunner?: IActionRunner;
private toolbar?: ToolBar;
private readonly showActionsAlways: boolean = false;
private headerContainer?: HTMLElement;
@@ -196,7 +194,6 @@ export abstract class ViewPane extends Pane implements IView {
this.id = options.id;
this.title = options.title;
this.actionRunner = options.actionRunner;
this.showActionsAlways = !!options.showActionsAlways;
this.focusedViewContextKey = FocusedViewContext.bindTo(contextKeyService);
@@ -262,7 +259,6 @@ export abstract class ViewPane extends Pane implements IView {
actionViewItemProvider: action => this.getActionViewItem(action),
ariaLabel: nls.localize('viewToolbarAriaLabel', "{0} actions", this.title),
getKeyBinding: action => this.keybindingService.lookupKeybinding(action.id),
actionRunner: this.actionRunner
});
this._register(this.toolbar);
@@ -311,7 +307,9 @@ export abstract class ViewPane extends Pane implements IView {
}
focus(): void {
if (this.element) {
if (this.shouldShowWelcome()) {
this.viewWelcomeContainer.focus();
} else if (this.element) {
this.element.focus();
this._onDidFocus.fire();
}
@@ -453,8 +451,6 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
private didLayout = false;
private dimension: Dimension | undefined;
protected actionRunner: IActionRunner | undefined;
private readonly visibleViewsCountFromCache: number | undefined;
private readonly visibleViewsStorageId: string;
protected readonly viewsModel: PersistentContributableViewsModel;
@@ -800,7 +796,6 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
{
id: viewDescriptor.id,
title: viewDescriptor.name,
actionRunner: this.getActionRunner(),
expanded: !collapsed,
minimumBodySize: this.viewDescriptorService.getViewContainerLocation(this.viewContainer) === ViewContainerLocation.Panel ? 0 : 120
});
@@ -831,14 +826,6 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
return panes;
}
getActionRunner(): IActionRunner {
if (!this.actionRunner) {
this.actionRunner = new ActionRunner();
}
return this.actionRunner;
}
private onDidRemoveViewDescriptors(removed: IViewDescriptorRef[]): void {
removed = removed.sort((a, b) => b.index - a.index);
const panesToRemove: ViewPane[] = [];