mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 01:25:36 -05:00
Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)
This commit is contained in:
@@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { ISashEvent, IVerticalSashLayoutProvider, Sash, SashState } from 'vs/base/browser/ui/sash/sash';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { RunOnceScheduler, IntervalTimer } from 'vs/base/common/async';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
@@ -159,17 +159,17 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
private _width: number;
|
||||
private _height: number;
|
||||
private _reviewHeight: number;
|
||||
private readonly _measureDomElementToken: number;
|
||||
private readonly _measureDomElementToken: IntervalTimer | null;
|
||||
|
||||
private originalEditor: CodeEditorWidget;
|
||||
private _originalDomNode: HTMLElement;
|
||||
private readonly originalEditor: CodeEditorWidget;
|
||||
private readonly _originalDomNode: HTMLElement;
|
||||
private readonly _originalEditorState: VisualEditorState;
|
||||
private _originalOverviewRuler: editorBrowser.IOverviewRuler;
|
||||
private _originalOverviewRuler: editorBrowser.IOverviewRuler | null;
|
||||
|
||||
private modifiedEditor: CodeEditorWidget;
|
||||
private _modifiedDomNode: HTMLElement;
|
||||
private readonly modifiedEditor: CodeEditorWidget;
|
||||
private readonly _modifiedDomNode: HTMLElement;
|
||||
private readonly _modifiedEditorState: VisualEditorState;
|
||||
private _modifiedOverviewRuler: editorBrowser.IOverviewRuler;
|
||||
private _modifiedOverviewRuler: editorBrowser.IOverviewRuler | null;
|
||||
|
||||
private _currentlyChangingViewZones: boolean;
|
||||
private _beginUpdateDecorationsTimeout: number;
|
||||
@@ -185,7 +185,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
private _renderSideBySide: boolean;
|
||||
private _renderIndicators: boolean;
|
||||
private _enableSplitViewResizing: boolean;
|
||||
private _strategy: IDiffEditorWidgetStyle;
|
||||
private _strategy!: IDiffEditorWidgetStyle;
|
||||
|
||||
private readonly _updateDecorationsRunner: RunOnceScheduler;
|
||||
|
||||
@@ -271,8 +271,19 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}));
|
||||
this._containerDomElement.appendChild(this._overviewDomElement);
|
||||
|
||||
this._createLeftHandSide();
|
||||
this._createRightHandSide();
|
||||
// Create left side
|
||||
this._originalDomNode = document.createElement('div');
|
||||
this._originalDomNode.className = 'editor original';
|
||||
this._originalDomNode.style.position = 'absolute';
|
||||
this._originalDomNode.style.height = '100%';
|
||||
this._containerDomElement.appendChild(this._originalDomNode);
|
||||
|
||||
// Create right side
|
||||
this._modifiedDomNode = document.createElement('div');
|
||||
this._modifiedDomNode.className = 'editor modified';
|
||||
this._modifiedDomNode.style.position = 'absolute';
|
||||
this._modifiedDomNode.style.height = '100%';
|
||||
this._containerDomElement.appendChild(this._modifiedDomNode);
|
||||
|
||||
this._beginUpdateDecorationsTimeout = -1;
|
||||
this._currentlyChangingViewZones = false;
|
||||
@@ -304,8 +315,11 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
rightServices.set(IContextKeyService, rightContextKeyService);
|
||||
const rightScopedInstantiationService = instantiationService.createChild(rightServices);
|
||||
|
||||
this._createLeftHandSideEditor(options, leftScopedInstantiationService);
|
||||
this._createRightHandSideEditor(options, rightScopedInstantiationService);
|
||||
this.originalEditor = this._createLeftHandSideEditor(options, leftScopedInstantiationService);
|
||||
this.modifiedEditor = this._createRightHandSideEditor(options, rightScopedInstantiationService);
|
||||
|
||||
this._originalOverviewRuler = null;
|
||||
this._modifiedOverviewRuler = null;
|
||||
|
||||
this._reviewPane = new DiffReview(this);
|
||||
this._containerDomElement.appendChild(this._reviewPane.domNode.domNode);
|
||||
@@ -313,7 +327,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._containerDomElement.appendChild(this._reviewPane.actionBarContainer.domNode);
|
||||
|
||||
if (options.automaticLayout) {
|
||||
this._measureDomElementToken = window.setInterval(() => this._measureDomElement(false), 100);
|
||||
this._measureDomElementToken = new IntervalTimer();
|
||||
this._measureDomElementToken.cancelAndSet(() => this._measureDomElement(false), 100);
|
||||
} else {
|
||||
this._measureDomElementToken = null;
|
||||
}
|
||||
|
||||
// enableSplitViewResizing
|
||||
@@ -393,26 +410,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._layoutOverviewRulers();
|
||||
}
|
||||
|
||||
private _createLeftHandSide(): void {
|
||||
this._originalDomNode = document.createElement('div');
|
||||
this._originalDomNode.className = 'editor original';
|
||||
this._originalDomNode.style.position = 'absolute';
|
||||
this._originalDomNode.style.height = '100%';
|
||||
this._containerDomElement.appendChild(this._originalDomNode);
|
||||
}
|
||||
private _createLeftHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
|
||||
const editor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable));
|
||||
|
||||
private _createRightHandSide(): void {
|
||||
this._modifiedDomNode = document.createElement('div');
|
||||
this._modifiedDomNode.className = 'editor modified';
|
||||
this._modifiedDomNode.style.position = 'absolute';
|
||||
this._modifiedDomNode.style.height = '100%';
|
||||
this._containerDomElement.appendChild(this._modifiedDomNode);
|
||||
}
|
||||
|
||||
private _createLeftHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): void {
|
||||
this.originalEditor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable));
|
||||
|
||||
this._register(this.originalEditor.onDidScrollChange((e) => {
|
||||
this._register(editor.onDidScrollChange((e) => {
|
||||
if (this._isHandlingScrollEvent) {
|
||||
return;
|
||||
}
|
||||
@@ -429,21 +430,23 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._layoutOverviewViewport();
|
||||
}));
|
||||
|
||||
this._register(this.originalEditor.onDidChangeViewZones(() => {
|
||||
this._register(editor.onDidChangeViewZones(() => {
|
||||
this._onViewZonesChanged();
|
||||
}));
|
||||
|
||||
this._register(this.originalEditor.onDidChangeModelContent(() => {
|
||||
this._register(editor.onDidChangeModelContent(() => {
|
||||
if (this._isVisible) {
|
||||
this._beginUpdateDecorationsSoon();
|
||||
}
|
||||
}));
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private _createRightHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): void {
|
||||
this.modifiedEditor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options));
|
||||
private _createRightHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
|
||||
const editor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options));
|
||||
|
||||
this._register(this.modifiedEditor.onDidScrollChange((e) => {
|
||||
this._register(editor.onDidScrollChange((e) => {
|
||||
if (this._isHandlingScrollEvent) {
|
||||
return;
|
||||
}
|
||||
@@ -460,21 +463,23 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._layoutOverviewViewport();
|
||||
}));
|
||||
|
||||
this._register(this.modifiedEditor.onDidChangeViewZones(() => {
|
||||
this._register(editor.onDidChangeViewZones(() => {
|
||||
this._onViewZonesChanged();
|
||||
}));
|
||||
|
||||
this._register(this.modifiedEditor.onDidChangeConfiguration((e) => {
|
||||
if (e.fontInfo && this.modifiedEditor.getModel()) {
|
||||
this._register(editor.onDidChangeConfiguration((e) => {
|
||||
if (e.fontInfo && editor.getModel()) {
|
||||
this._onViewZonesChanged();
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this.modifiedEditor.onDidChangeModelContent(() => {
|
||||
this._register(editor.onDidChangeModelContent(() => {
|
||||
if (this._isVisible) {
|
||||
this._beginUpdateDecorationsSoon();
|
||||
}
|
||||
}));
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
protected _createInnerEditor(instantiationService: IInstantiationService, container: HTMLElement, options: editorOptions.IEditorOptions): CodeEditorWidget {
|
||||
@@ -489,7 +494,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._beginUpdateDecorationsTimeout = -1;
|
||||
}
|
||||
|
||||
window.clearInterval(this._measureDomElementToken);
|
||||
if (this._measureDomElementToken) {
|
||||
this._measureDomElementToken.dispose();
|
||||
}
|
||||
|
||||
this._cleanViewZonesAndDecorations();
|
||||
|
||||
@@ -825,6 +832,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
|
||||
private _layoutOverviewRulers(): void {
|
||||
if (!this._originalOverviewRuler || !this._modifiedOverviewRuler) {
|
||||
return;
|
||||
}
|
||||
let freeSpace = DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH - 2 * DiffEditorWidget.ONE_OVERVIEW_WIDTH;
|
||||
let layoutInfo = this.modifiedEditor.getLayoutInfo();
|
||||
if (layoutInfo) {
|
||||
@@ -926,7 +936,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
|
||||
private _updateDecorations(): void {
|
||||
if (!this.originalEditor.getModel() || !this.modifiedEditor.getModel()) {
|
||||
if (!this.originalEditor.getModel() || !this.modifiedEditor.getModel() || !this._originalOverviewRuler || !this._modifiedOverviewRuler) {
|
||||
return;
|
||||
}
|
||||
const lineChanges = (this._diffComputationResult ? this._diffComputationResult.changes : []);
|
||||
@@ -1194,12 +1204,14 @@ interface IDataSource {
|
||||
abstract class DiffEditorWidgetStyle extends Disposable implements IDiffEditorWidgetStyle {
|
||||
|
||||
_dataSource: IDataSource;
|
||||
_insertColor: Color;
|
||||
_removeColor: Color;
|
||||
_insertColor: Color | null;
|
||||
_removeColor: Color | null;
|
||||
|
||||
constructor(dataSource: IDataSource) {
|
||||
super();
|
||||
this._dataSource = dataSource;
|
||||
this._insertColor = null;
|
||||
this._removeColor = null;
|
||||
}
|
||||
|
||||
public applyColors(theme: ITheme): boolean {
|
||||
@@ -1277,6 +1289,7 @@ class ForeignViewZonesIterator {
|
||||
constructor(source: IEditorWhitespace[]) {
|
||||
this._source = source;
|
||||
this._index = -1;
|
||||
this.current = null;
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@@ -1555,7 +1568,7 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffE
|
||||
private readonly _sash: Sash;
|
||||
private _sashRatio: number | null;
|
||||
private _sashPosition: number | null;
|
||||
private _startSashPosition: number;
|
||||
private _startSashPosition: number | null;
|
||||
|
||||
constructor(dataSource: IDataSource, enableSplitViewResizing: boolean) {
|
||||
super(dataSource);
|
||||
@@ -1563,6 +1576,7 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffE
|
||||
this._disableSash = (enableSplitViewResizing === false);
|
||||
this._sashRatio = null;
|
||||
this._sashPosition = null;
|
||||
this._startSashPosition = null;
|
||||
this._sash = this._register(new Sash(this._dataSource.getContainerDomNode(), this));
|
||||
|
||||
if (this._disableSash) {
|
||||
@@ -1619,7 +1633,7 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffE
|
||||
private onSashDrag(e: ISashEvent): void {
|
||||
let w = this._dataSource.getWidth();
|
||||
let contentWidth = w - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
|
||||
let sashPosition = this.layout((this._startSashPosition + (e.currentX - e.startX)) / contentWidth);
|
||||
let sashPosition = this.layout((this._startSashPosition! + (e.currentX - e.startX)) / contentWidth);
|
||||
|
||||
this._sashRatio = sashPosition / contentWidth;
|
||||
|
||||
@@ -1654,7 +1668,7 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffE
|
||||
}
|
||||
|
||||
protected _getOriginalEditorDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorDiffDecorations {
|
||||
const overviewZoneColor = this._removeColor.toString();
|
||||
const overviewZoneColor = String(this._removeColor);
|
||||
|
||||
let result: IEditorDiffDecorations = {
|
||||
decorations: [],
|
||||
@@ -1714,7 +1728,7 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffE
|
||||
}
|
||||
|
||||
protected _getModifiedEditorDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorDiffDecorations {
|
||||
const overviewZoneColor = this._insertColor.toString();
|
||||
const overviewZoneColor = String(this._insertColor);
|
||||
|
||||
let result: IEditorDiffDecorations = {
|
||||
decorations: [],
|
||||
@@ -1834,7 +1848,7 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle implements IDiffEdito
|
||||
}
|
||||
|
||||
protected _getOriginalEditorDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorDiffDecorations {
|
||||
const overviewZoneColor = this._removeColor.toString();
|
||||
const overviewZoneColor = String(this._removeColor);
|
||||
|
||||
let result: IEditorDiffDecorations = {
|
||||
decorations: [],
|
||||
@@ -1863,7 +1877,7 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle implements IDiffEdito
|
||||
}
|
||||
|
||||
protected _getModifiedEditorDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorDiffDecorations {
|
||||
const overviewZoneColor = this._insertColor.toString();
|
||||
const overviewZoneColor = String(this._insertColor);
|
||||
|
||||
let result: IEditorDiffDecorations = {
|
||||
decorations: [],
|
||||
|
||||
Reference in New Issue
Block a user