mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
Merge remote-tracking branch 'origin/master' into alex/tokenization
This commit is contained in:
@@ -110,7 +110,7 @@ export class ResourceLabel extends IconLabel {
|
||||
const resource = this.label.resource;
|
||||
|
||||
let title = '';
|
||||
if (this.options && this.options.title) {
|
||||
if (this.options && typeof this.options.title === 'string') {
|
||||
title = this.options.title;
|
||||
} else if (resource) {
|
||||
title = getPathLabel(resource.fsPath);
|
||||
|
||||
@@ -758,7 +758,7 @@ export class EditorGroupsControl implements IEditorGroupsControl, IVerticalSashL
|
||||
this.sashTwo.setOrientation(this.layoutVertically ? Orientation.VERTICAL : Orientation.HORIZONTAL);
|
||||
|
||||
// Trigger layout
|
||||
this.arrangeGroups(GroupArrangement.EVEN);
|
||||
this.arrangeGroups();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ export class EditorGroupsControl implements IEditorGroupsControl, IVerticalSashL
|
||||
return this.layoutVertically ? 'vertical' : 'horizontal';
|
||||
}
|
||||
|
||||
public arrangeGroups(arrangement: GroupArrangement): void {
|
||||
public arrangeGroups(arrangement?: GroupArrangement): void {
|
||||
if (!this.dimension) {
|
||||
return; // too early
|
||||
}
|
||||
@@ -778,27 +778,49 @@ export class EditorGroupsControl implements IEditorGroupsControl, IVerticalSashL
|
||||
return; // need more editors
|
||||
}
|
||||
|
||||
// Minimize Others
|
||||
if (arrangement === GroupArrangement.MINIMIZE_OTHERS) {
|
||||
POSITIONS.forEach(position => {
|
||||
if (this.visibleEditors[position]) {
|
||||
if (position !== this.lastActivePosition) {
|
||||
this.silosSize[position] = this.minSize;
|
||||
availableSize -= this.minSize;
|
||||
switch (arrangement) {
|
||||
case GroupArrangement.MINIMIZE_OTHERS:
|
||||
// Minimize Others
|
||||
POSITIONS.forEach(position => {
|
||||
if (this.visibleEditors[position]) {
|
||||
if (position !== this.lastActivePosition) {
|
||||
this.silosSize[position] = this.minSize;
|
||||
availableSize -= this.minSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.silosSize[this.lastActivePosition] = availableSize;
|
||||
}
|
||||
this.silosSize[this.lastActivePosition] = availableSize;
|
||||
break;
|
||||
case GroupArrangement.EVEN:
|
||||
// Even Sizes
|
||||
POSITIONS.forEach(position => {
|
||||
if (this.visibleEditors[position]) {
|
||||
this.silosSize[position] = availableSize / visibleEditors;
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
// Minimized editors should remain minimized, others should keep their relative Sizes
|
||||
let oldNonMinimizedTotal = 0;
|
||||
POSITIONS.forEach(position => {
|
||||
if (this.visibleEditors[position]) {
|
||||
if (this.silosMinimized[position]) {
|
||||
this.silosSize[position] = this.minSize;
|
||||
availableSize -= this.minSize;
|
||||
} else {
|
||||
oldNonMinimizedTotal += this.silosSize[position];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Even Sizes
|
||||
else if (arrangement === GroupArrangement.EVEN) {
|
||||
POSITIONS.forEach(position => {
|
||||
if (this.visibleEditors[position]) {
|
||||
this.silosSize[position] = availableSize / visibleEditors;
|
||||
}
|
||||
});
|
||||
// Set size for non-minimized editors
|
||||
const scaleFactor = availableSize / oldNonMinimizedTotal;
|
||||
POSITIONS.forEach(position => {
|
||||
if (this.visibleEditors[position] && !this.silosMinimized[position]) {
|
||||
this.silosSize[position] *= scaleFactor;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Since we triggered a change in minimized/maximized editors, we need
|
||||
|
||||
@@ -9,13 +9,12 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Dimension, Builder } from 'vs/base/browser/builder';
|
||||
import objects = require('vs/base/common/objects');
|
||||
import errors = require('vs/base/common/errors');
|
||||
import types = require('vs/base/common/types');
|
||||
import DOM = require('vs/base/browser/dom');
|
||||
import { CodeEditor } from 'vs/editor/browser/codeEditor';
|
||||
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorConfiguration } from 'vs/editor/common/config/commonEditorConfig';
|
||||
import { IEditorViewState, IEditor, IEditorOptions, EventType as EditorEventType } from 'vs/editor/common/editorCommon';
|
||||
import { IFilesConfiguration } from 'vs/platform/files/common/files';
|
||||
import { IEditorViewState, IEditor, IEditorOptions, EventType as EditorEventType, EditorType } from 'vs/editor/common/editorCommon';
|
||||
import { Position } from 'vs/platform/editor/common/editor';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -34,6 +33,11 @@ interface ITextEditorViewState {
|
||||
2?: IEditorViewState;
|
||||
}
|
||||
|
||||
interface IEditorConfiguration {
|
||||
editor: any;
|
||||
diffEditor: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base class of editors that leverage the text editor for the editing experience. This class is only intended to
|
||||
* be subclassed and not instantiated.
|
||||
@@ -56,14 +60,14 @@ export abstract class BaseTextEditor extends BaseEditor {
|
||||
super(id, telemetryService);
|
||||
|
||||
this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(e => this.handleConfigurationChangeEvent(e.config)));
|
||||
this.toUnbind.push(themeService.onDidColorThemeChange(_ => this.handleConfigurationChangeEvent()));
|
||||
this.toUnbind.push(themeService.onDidColorThemeChange(e => this.handleConfigurationChangeEvent(this.configurationService.getConfiguration<IEditorConfiguration>())));
|
||||
}
|
||||
|
||||
protected get instantiationService(): IInstantiationService {
|
||||
return this._instantiationService;
|
||||
}
|
||||
|
||||
private handleConfigurationChangeEvent(configuration?: any): void {
|
||||
private handleConfigurationChangeEvent(configuration: IEditorConfiguration): void {
|
||||
if (this.isVisible()) {
|
||||
this.applyConfiguration(configuration);
|
||||
} else {
|
||||
@@ -73,28 +77,27 @@ export abstract class BaseTextEditor extends BaseEditor {
|
||||
|
||||
private consumePendingConfigurationChangeEvent(): void {
|
||||
if (this.hasPendingConfigurationChange) {
|
||||
this.applyConfiguration(this.configurationService.getConfiguration());
|
||||
this.applyConfiguration(this.configurationService.getConfiguration<IEditorConfiguration>());
|
||||
this.hasPendingConfigurationChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected applyConfiguration(configuration?: any): void {
|
||||
private applyConfiguration(configuration: IEditorConfiguration): void {
|
||||
if (!this.editorControl) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Configuration & Options
|
||||
if (configuration) {
|
||||
const specificEditorSettings = this.getCodeEditorOptions();
|
||||
configuration = objects.clone(configuration); // dont modify original config
|
||||
objects.assign(configuration[EditorConfiguration.EDITOR_SECTION], specificEditorSettings);
|
||||
EditorConfiguration.apply(configuration, this.editorControl);
|
||||
// Specific editor options always overwrite user configuration
|
||||
const editorConfiguration = types.isObject(configuration.editor) ? objects.clone(configuration.editor) : Object.create(null);
|
||||
objects.assign(editorConfiguration, this.getCodeEditorOptions());
|
||||
|
||||
// Handle diff editor specially by merging in diffEditor configuration
|
||||
if (this.editorControl.getEditorType() === EditorType.IDiffEditor && types.isObject(configuration.diffEditor)) {
|
||||
objects.mixin(editorConfiguration, configuration.diffEditor);
|
||||
}
|
||||
|
||||
// Just options
|
||||
else {
|
||||
this.editorControl.updateOptions(this.getCodeEditorOptions());
|
||||
}
|
||||
// Apply to control
|
||||
this.editorControl.updateOptions(editorConfiguration);
|
||||
}
|
||||
|
||||
protected getCodeEditorOptions(): IEditorOptions {
|
||||
@@ -119,7 +122,7 @@ export abstract class BaseTextEditor extends BaseEditor {
|
||||
this.toUnbind.push(DOM.addDisposableListener(window, DOM.EventType.BLUR, () => this.onWindowFocusLost()));
|
||||
|
||||
// Configuration
|
||||
this.applyConfiguration(this.configurationService.getConfiguration<IFilesConfiguration>());
|
||||
this.applyConfiguration(this.configurationService.getConfiguration<IEditorConfiguration>());
|
||||
}
|
||||
|
||||
private onEditorFocusLost(): void {
|
||||
|
||||
Reference in New Issue
Block a user