mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from master
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3,45 +3,43 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./media/diffEditor';
|
||||
import * as nls from 'vs/nls';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
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 { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
|
||||
import { renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { Configuration } from 'vs/editor/browser/config/configuration';
|
||||
import { Position, IPosition } from 'vs/editor/common/core/position';
|
||||
import { Selection, ISelection } from 'vs/editor/common/core/selection';
|
||||
import { InlineDecoration, InlineDecorationType, ViewLineRenderingData } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { registerThemingParticipant, IThemeService, ITheme, getThemeTypeSelector } from 'vs/platform/theme/common/themeService';
|
||||
import { scrollbarShadow, diffInserted, diffRemoved, defaultInsertColor, defaultRemoveColor, diffInsertedOutline, diffRemovedOutline, diffBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { OverviewRulerZone } from 'vs/editor/common/view/overviewZoneManager';
|
||||
import { IEditorWhitespace } from 'vs/editor/common/viewLayout/whitespaceComputer';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { DiffReview } from 'vs/editor/browser/widget/diffReview';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IStringBuilder, createStringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import { IModelDeltaDecoration, IModelDecorationsChangeAccessor, ITextModel } from 'vs/editor/common/model';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Configuration } from 'vs/editor/browser/config/configuration';
|
||||
import { StableEditorScrollState } from 'vs/editor/browser/core/editorState';
|
||||
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { DiffReview } from 'vs/editor/browser/widget/diffReview';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { ISelection, Selection } from 'vs/editor/common/core/selection';
|
||||
import { IStringBuilder, createStringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { IModelDecorationsChangeAccessor, IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { IDiffComputationResult, IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { OverviewRulerZone } from 'vs/editor/common/view/overviewZoneManager';
|
||||
import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
|
||||
import { RenderLineInput, renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { IEditorWhitespace } from 'vs/editor/common/viewLayout/whitespaceComputer';
|
||||
import { InlineDecoration, InlineDecorationType, ViewLineRenderingData } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { defaultInsertColor, defaultRemoveColor, diffBorder, diffInserted, diffInsertedOutline, diffRemoved, diffRemovedOutline, scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { ITheme, IThemeService, getThemeTypeSelector, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
interface IEditorDiffDecorations {
|
||||
decorations: IModelDeltaDecoration[];
|
||||
@@ -173,7 +171,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
private _currentlyChangingViewZones: boolean;
|
||||
private _beginUpdateDecorationsTimeout: number;
|
||||
private _diffComputationToken: number;
|
||||
private _lineChanges: editorCommon.ILineChange[];
|
||||
private _diffComputationResult: IDiffComputationResult | null;
|
||||
|
||||
private _isVisible: boolean;
|
||||
private _isHandlingScrollEvent: boolean;
|
||||
@@ -283,7 +281,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._height = 0;
|
||||
this._reviewHeight = 0;
|
||||
|
||||
this._lineChanges = null;
|
||||
this._diffComputationResult = null;
|
||||
|
||||
const leftContextKeyService = this._contextKeyService.createScoped();
|
||||
leftContextKeyService.createKey('isInDiffLeftEditor', true);
|
||||
@@ -525,8 +523,11 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return editorCommon.EditorType.IDiffEditor;
|
||||
}
|
||||
|
||||
public getLineChanges(): editorCommon.ILineChange[] {
|
||||
return this._lineChanges;
|
||||
public getLineChanges(): editorCommon.ILineChange[] | null {
|
||||
if (!this._diffComputationResult) {
|
||||
return null;
|
||||
}
|
||||
return this._diffComputationResult.changes;
|
||||
}
|
||||
|
||||
public getOriginalEditor(): editorBrowser.ICodeEditor {
|
||||
@@ -585,7 +586,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
// renderSideBySide
|
||||
if (renderSideBySideChanged) {
|
||||
if (this._renderSideBySide) {
|
||||
this._setStrategy(new DiffEdtorWidgetSideBySide(this._createDataSource(), this._enableSplitViewResizing, ));
|
||||
this._setStrategy(new DiffEdtorWidgetSideBySide(this._createDataSource(), this._enableSplitViewResizing));
|
||||
} else {
|
||||
this._setStrategy(new DiffEdtorWidgetInline(this._createDataSource(), this._enableSplitViewResizing));
|
||||
}
|
||||
@@ -621,7 +622,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
|
||||
// Disable any diff computations that will come in
|
||||
this._lineChanges = null;
|
||||
this._diffComputationResult = null;
|
||||
this._diffComputationToken++;
|
||||
|
||||
if (model) {
|
||||
@@ -630,7 +631,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
// Begin comparing
|
||||
this._beginUpdateDecorations();
|
||||
} else {
|
||||
this._lineChanges = null;
|
||||
this._diffComputationResult = null;
|
||||
}
|
||||
|
||||
this._layoutOverviewViewport();
|
||||
@@ -644,7 +645,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return this.modifiedEditor.getVisibleColumnFromPosition(position);
|
||||
}
|
||||
|
||||
public getPosition(): Position {
|
||||
public getPosition(): Position | null {
|
||||
return this.modifiedEditor.getPosition();
|
||||
}
|
||||
|
||||
@@ -676,11 +677,11 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this.modifiedEditor.revealPositionInCenterIfOutsideViewport(position, scrollType);
|
||||
}
|
||||
|
||||
public getSelection(): Selection {
|
||||
public getSelection(): Selection | null {
|
||||
return this.modifiedEditor.getSelection();
|
||||
}
|
||||
|
||||
public getSelections(): Selection[] {
|
||||
public getSelections(): Selection[] | null {
|
||||
return this.modifiedEditor.getSelections();
|
||||
}
|
||||
|
||||
@@ -849,10 +850,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._beginUpdateDecorationsTimeout = window.setTimeout(() => this._beginUpdateDecorations(), DiffEditorWidget.UPDATE_DIFF_DECORATIONS_DELAY);
|
||||
}
|
||||
|
||||
private _lastOriginalWarning: URI = null;
|
||||
private _lastModifiedWarning: URI = null;
|
||||
private _lastOriginalWarning: URI | null = null;
|
||||
private _lastModifiedWarning: URI | null = null;
|
||||
|
||||
private static _equals(a: URI, b: URI): boolean {
|
||||
private static _equals(a: URI | null, b: URI | null): boolean {
|
||||
if (!a && !b) {
|
||||
return true;
|
||||
}
|
||||
@@ -893,7 +894,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
&& currentOriginalModel === this.originalEditor.getModel()
|
||||
&& currentModifiedModel === this.modifiedEditor.getModel()
|
||||
) {
|
||||
this._lineChanges = result;
|
||||
this._diffComputationResult = result;
|
||||
this._updateDecorationsRunner.schedule();
|
||||
this._onDidUpdateDiff.fire();
|
||||
}
|
||||
@@ -902,7 +903,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
&& currentOriginalModel === this.originalEditor.getModel()
|
||||
&& currentModifiedModel === this.modifiedEditor.getModel()
|
||||
) {
|
||||
this._lineChanges = null;
|
||||
this._diffComputationResult = null;
|
||||
this._updateDecorationsRunner.schedule();
|
||||
}
|
||||
});
|
||||
@@ -917,7 +918,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
if (!this.originalEditor.getModel() || !this.modifiedEditor.getModel()) {
|
||||
return;
|
||||
}
|
||||
let lineChanges = this._lineChanges || [];
|
||||
const lineChanges = (this._diffComputationResult ? this._diffComputationResult.changes : []);
|
||||
|
||||
let foreignOriginal = this._originalEditorState.getForeignViewZones(this.originalEditor.getWhitespaces());
|
||||
let foreignModified = this._modifiedEditorState.getForeignViewZones(this.modifiedEditor.getWhitespaces());
|
||||
@@ -944,7 +945,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
clonedOptions.folding = false;
|
||||
clonedOptions.codeLens = false;
|
||||
clonedOptions.fixedOverflowWidgets = true;
|
||||
clonedOptions.lineDecorationsWidth = '2ch';
|
||||
// clonedOptions.lineDecorationsWidth = '2ch';
|
||||
if (!clonedOptions.minimap) {
|
||||
clonedOptions.minimap = {};
|
||||
}
|
||||
@@ -1011,7 +1012,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
}
|
||||
|
||||
private _computeOverviewViewport(): { height: number; top: number; } {
|
||||
private _computeOverviewViewport(): { height: number; top: number; } | null {
|
||||
let layoutInfo = this.modifiedEditor.getLayoutInfo();
|
||||
if (!layoutInfo) {
|
||||
return null;
|
||||
@@ -1069,7 +1070,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._strategy = newStrategy;
|
||||
newStrategy.applyColors(this._themeService.getTheme());
|
||||
|
||||
if (this._lineChanges) {
|
||||
if (this._diffComputationResult) {
|
||||
this._updateDecorations();
|
||||
}
|
||||
|
||||
@@ -1077,17 +1078,18 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._measureDomElement(true);
|
||||
}
|
||||
|
||||
private _getLineChangeAtOrBeforeLineNumber(lineNumber: number, startLineNumberExtractor: (lineChange: editorCommon.ILineChange) => number): editorCommon.ILineChange {
|
||||
if (this._lineChanges.length === 0 || lineNumber < startLineNumberExtractor(this._lineChanges[0])) {
|
||||
private _getLineChangeAtOrBeforeLineNumber(lineNumber: number, startLineNumberExtractor: (lineChange: editorCommon.ILineChange) => number): editorCommon.ILineChange | null {
|
||||
const lineChanges = (this._diffComputationResult ? this._diffComputationResult.changes : []);
|
||||
if (lineChanges.length === 0 || lineNumber < startLineNumberExtractor(lineChanges[0])) {
|
||||
// There are no changes or `lineNumber` is before the first change
|
||||
return null;
|
||||
}
|
||||
|
||||
let min = 0, max = this._lineChanges.length - 1;
|
||||
let min = 0, max = lineChanges.length - 1;
|
||||
while (min < max) {
|
||||
let mid = Math.floor((min + max) / 2);
|
||||
let midStart = startLineNumberExtractor(this._lineChanges[mid]);
|
||||
let midEnd = (mid + 1 <= max ? startLineNumberExtractor(this._lineChanges[mid + 1]) : Number.MAX_VALUE);
|
||||
let midStart = startLineNumberExtractor(lineChanges[mid]);
|
||||
let midEnd = (mid + 1 <= max ? startLineNumberExtractor(lineChanges[mid + 1]) : Number.MAX_VALUE);
|
||||
|
||||
if (lineNumber < midStart) {
|
||||
max = mid - 1;
|
||||
@@ -1099,7 +1101,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
max = mid;
|
||||
}
|
||||
}
|
||||
return this._lineChanges[min];
|
||||
return lineChanges[min];
|
||||
}
|
||||
|
||||
private _getEquivalentLineForOriginalLineNumber(lineNumber: number): number {
|
||||
@@ -1146,8 +1148,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return originalEquivalentLineNumber + lineChangeOriginalLength - lineChangeModifiedLength + delta;
|
||||
}
|
||||
|
||||
public getDiffLineInformationForOriginal(lineNumber: number): editorBrowser.IDiffLineInformation {
|
||||
if (!this._lineChanges) {
|
||||
public getDiffLineInformationForOriginal(lineNumber: number): editorBrowser.IDiffLineInformation | null {
|
||||
if (!this._diffComputationResult) {
|
||||
// Cannot answer that which I don't know
|
||||
return null;
|
||||
}
|
||||
@@ -1156,8 +1158,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
};
|
||||
}
|
||||
|
||||
public getDiffLineInformationForModified(lineNumber: number): editorBrowser.IDiffLineInformation {
|
||||
if (!this._lineChanges) {
|
||||
public getDiffLineInformationForModified(lineNumber: number): editorBrowser.IDiffLineInformation | null {
|
||||
if (!this._diffComputationResult) {
|
||||
// Cannot answer that which I don't know
|
||||
return null;
|
||||
}
|
||||
@@ -1233,15 +1235,20 @@ abstract class DiffEditorWidgetStyle extends Disposable implements IDiffEditorWi
|
||||
public abstract layout(): number;
|
||||
}
|
||||
|
||||
interface IMyViewZone extends editorBrowser.IViewZone {
|
||||
interface IMyViewZone {
|
||||
shouldNotShrink?: boolean;
|
||||
afterLineNumber: number;
|
||||
heightInLines: number;
|
||||
minWidthInPx?: number;
|
||||
domNode: HTMLElement | null;
|
||||
marginDomNode?: HTMLElement | null;
|
||||
}
|
||||
|
||||
class ForeignViewZonesIterator {
|
||||
|
||||
private _index: number;
|
||||
private _source: IEditorWhitespace[];
|
||||
public current: IEditorWhitespace;
|
||||
public current: IEditorWhitespace | null;
|
||||
|
||||
constructor(source: IEditorWhitespace[]) {
|
||||
this._source = source;
|
||||
@@ -1272,7 +1279,7 @@ abstract class ViewZonesComputer {
|
||||
}
|
||||
|
||||
public getViewZones(): IEditorsZones {
|
||||
let result: IEditorsZones = {
|
||||
let result: { original: IMyViewZone[]; modified: IMyViewZone[]; } = {
|
||||
original: [],
|
||||
modified: []
|
||||
};
|
||||
@@ -1288,7 +1295,7 @@ abstract class ViewZonesComputer {
|
||||
return a.afterLineNumber - b.afterLineNumber;
|
||||
};
|
||||
|
||||
let addAndCombineIfPossible = (destination: editorBrowser.IViewZone[], item: IMyViewZone) => {
|
||||
let addAndCombineIfPossible = (destination: IMyViewZone[], item: IMyViewZone) => {
|
||||
if (item.domNode === null && destination.length > 0) {
|
||||
let lastItem = destination[destination.length - 1];
|
||||
if (lastItem.afterLineNumber === item.afterLineNumber && lastItem.domNode === null) {
|
||||
@@ -1335,10 +1342,17 @@ abstract class ViewZonesComputer {
|
||||
} else {
|
||||
viewZoneLineNumber = originalEndEquivalentLineNumber;
|
||||
}
|
||||
|
||||
let marginDomNode: HTMLDivElement | null = null;
|
||||
if (lineChange && lineChange.modifiedStartLineNumber <= modifiedForeignVZ.current.afterLineNumber && modifiedForeignVZ.current.afterLineNumber <= lineChange.modifiedEndLineNumber) {
|
||||
marginDomNode = this._createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion();
|
||||
}
|
||||
|
||||
stepOriginal.push({
|
||||
afterLineNumber: viewZoneLineNumber,
|
||||
heightInLines: modifiedForeignVZ.current.heightInLines,
|
||||
domNode: null
|
||||
domNode: null,
|
||||
marginDomNode: marginDomNode
|
||||
});
|
||||
modifiedForeignVZ.advance();
|
||||
}
|
||||
@@ -1444,9 +1458,11 @@ abstract class ViewZonesComputer {
|
||||
return result;
|
||||
}
|
||||
|
||||
protected abstract _produceOriginalFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone;
|
||||
protected abstract _createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion(): HTMLDivElement | null;
|
||||
|
||||
protected abstract _produceModifiedFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone;
|
||||
protected abstract _produceOriginalFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone | null;
|
||||
|
||||
protected abstract _produceModifiedFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone | null;
|
||||
}
|
||||
|
||||
function createDecoration(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, options: ModelDecorationOptions) {
|
||||
@@ -1737,7 +1753,11 @@ class SideBySideViewZonesComputer extends ViewZonesComputer {
|
||||
super(lineChanges, originalForeignVZ, modifiedForeignVZ);
|
||||
}
|
||||
|
||||
protected _produceOriginalFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone {
|
||||
protected _createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion(): HTMLDivElement | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected _produceOriginalFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone | null {
|
||||
if (lineChangeModifiedLength > lineChangeOriginalLength) {
|
||||
return {
|
||||
afterLineNumber: Math.max(lineChange.originalStartLineNumber, lineChange.originalEndLineNumber),
|
||||
@@ -1748,7 +1768,7 @@ class SideBySideViewZonesComputer extends ViewZonesComputer {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected _produceModifiedFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone {
|
||||
protected _produceModifiedFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone | null {
|
||||
if (lineChangeOriginalLength > lineChangeModifiedLength) {
|
||||
return {
|
||||
afterLineNumber: Math.max(lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber),
|
||||
@@ -1897,10 +1917,15 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
this.renderIndicators = renderIndicators;
|
||||
}
|
||||
|
||||
protected _produceOriginalFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone {
|
||||
protected _createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion(): HTMLDivElement | null {
|
||||
let result = document.createElement('div');
|
||||
result.className = 'inline-added-margin-view-zone';
|
||||
return result;
|
||||
}
|
||||
|
||||
protected _produceOriginalFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone | null {
|
||||
let marginDomNode = document.createElement('div');
|
||||
marginDomNode.className = 'inline-added-margin-view-zone';
|
||||
Configuration.applyFontInfoSlow(marginDomNode, this.modifiedEditorConfiguration.fontInfo);
|
||||
|
||||
return {
|
||||
afterLineNumber: Math.max(lineChange.originalStartLineNumber, lineChange.originalEndLineNumber),
|
||||
@@ -1910,7 +1935,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
};
|
||||
}
|
||||
|
||||
protected _produceModifiedFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone {
|
||||
protected _produceModifiedFromDiff(lineChange: editorCommon.ILineChange, lineChangeOriginalLength: number, lineChangeModifiedLength: number): IMyViewZone | null {
|
||||
let decorations: InlineDecoration[] = [];
|
||||
if (lineChange.charChanges) {
|
||||
for (let j = 0, lengthJ = lineChange.charChanges.length; j < lengthJ; j++) {
|
||||
@@ -1982,6 +2007,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
const containsRTL = ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, originalModel.mightContainRTL());
|
||||
const output = renderViewLine(new RenderLineInput(
|
||||
(config.fontInfo.isMonospace && !config.viewInfo.disableMonospaceOptimizations),
|
||||
config.fontInfo.canUseHalfwidthRightwardsArrow,
|
||||
lineContent,
|
||||
false,
|
||||
isBasicASCII,
|
||||
@@ -2048,7 +2074,7 @@ registerThemingParticipant((theme, collector) => {
|
||||
collector.addRule(`.monaco-diff-editor.side-by-side .editor.modified { box-shadow: -6px 0 5px -5px ${shadow}; }`);
|
||||
}
|
||||
|
||||
let border = theme.getColor(diffBorder);
|
||||
const border = theme.getColor(diffBorder);
|
||||
if (border) {
|
||||
collector.addRule(`.monaco-diff-editor.side-by-side .editor.modified { border-left: 1px solid ${border}; }`);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'vs/base/common/assert';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ILineChange, ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
|
||||
interface IDiffRange {
|
||||
@@ -59,7 +58,7 @@ export class DiffNavigator {
|
||||
this.nextIdx = -1;
|
||||
this.ranges = [];
|
||||
this.ignoreSelectionChange = false;
|
||||
this.revealFirst = this._options.alwaysRevealFirst;
|
||||
this.revealFirst = Boolean(this._options.alwaysRevealFirst);
|
||||
|
||||
// hook up to diff editor for diff, disposal, and caret move
|
||||
this._disposables.push(this._editor.onDidDispose(() => this.dispose()));
|
||||
@@ -104,7 +103,7 @@ export class DiffNavigator {
|
||||
}
|
||||
}
|
||||
|
||||
private _compute(lineChanges: ILineChange[]): void {
|
||||
private _compute(lineChanges: ILineChange[] | null): void {
|
||||
|
||||
// new ranges
|
||||
this.ranges = [];
|
||||
@@ -151,6 +150,10 @@ export class DiffNavigator {
|
||||
private _initIdx(fwd: boolean): void {
|
||||
let found = false;
|
||||
let position = this._editor.getPosition();
|
||||
if (!position) {
|
||||
this.nextIdx = 0;
|
||||
return;
|
||||
}
|
||||
for (let i = 0, len = this.ranges.length; i < len && !found; i++) {
|
||||
let range = this.ranges[i].range;
|
||||
if (position.isBeforeOrEqual(range.getStartPosition())) {
|
||||
@@ -216,7 +219,7 @@ export class DiffNavigator {
|
||||
dispose(this._disposables);
|
||||
this._disposables.length = 0;
|
||||
this._onDidUpdate.dispose();
|
||||
this.ranges = null;
|
||||
this.ranges = [];
|
||||
this.disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,35 +2,34 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./media/diffReview';
|
||||
import * as nls from 'vs/nls';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { renderViewLine2 as renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { Configuration } from 'vs/editor/browser/config/configuration';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { ColorId, MetadataConsts, FontStyle } from 'vs/editor/common/modes';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { registerEditorAction, EditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Configuration } from 'vs/editor/browser/config/configuration';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { ILineChange, ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel, TextModelResolvedOptions } from 'vs/editor/common/model';
|
||||
import { ColorId, FontStyle, MetadataConsts } from 'vs/editor/common/modes';
|
||||
import { editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry';
|
||||
import { RenderLineInput, renderViewLine2 as renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { ViewLineRenderingData } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
const DIFF_LINES_PADDING = 3;
|
||||
|
||||
@@ -263,7 +262,7 @@ export class DiffReview extends Disposable {
|
||||
|
||||
if (jumpToLineNumber !== -1) {
|
||||
this._diffEditor.setPosition(new Position(jumpToLineNumber, 1));
|
||||
this._diffEditor.revealPosition(new Position(jumpToLineNumber, 1), editorCommon.ScrollType.Immediate);
|
||||
this._diffEditor.revealPosition(new Position(jumpToLineNumber, 1), ScrollType.Immediate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +358,7 @@ export class DiffReview extends Disposable {
|
||||
return DiffReview._mergeAdjacent(lineChanges, originalModel.getLineCount(), modifiedModel.getLineCount());
|
||||
}
|
||||
|
||||
private static _mergeAdjacent(lineChanges: editorCommon.ILineChange[], originalLineCount: number, modifiedLineCount: number): Diff[] {
|
||||
private static _mergeAdjacent(lineChanges: ILineChange[], originalLineCount: number, modifiedLineCount: number): Diff[] {
|
||||
if (!lineChanges || lineChanges.length === 0) {
|
||||
return [];
|
||||
}
|
||||
@@ -769,6 +768,7 @@ export class DiffReview extends Disposable {
|
||||
const containsRTL = ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, model.mightContainRTL());
|
||||
const r = renderViewLine(new RenderLineInput(
|
||||
(config.fontInfo.isMonospace && !config.viewInfo.disableMonospaceOptimizations),
|
||||
config.fontInfo.canUseHalfwidthRightwardsArrow,
|
||||
lineContent,
|
||||
false,
|
||||
isBasicASCII,
|
||||
@@ -791,7 +791,7 @@ export class DiffReview extends Disposable {
|
||||
// theming
|
||||
|
||||
registerThemingParticipant((theme, collector) => {
|
||||
let lineNumbers = theme.getColor(editorLineNumbers);
|
||||
const lineNumbers = theme.getColor(editorLineNumbers);
|
||||
if (lineNumbers) {
|
||||
collector.addRule(`.monaco-diff-editor .diff-review-line-number { color: ${lineNumbers}; }`);
|
||||
}
|
||||
|
||||
@@ -2,20 +2,19 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { IConfigurationChangedEvent, IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { IConfigurationChangedEvent, IEditorOptions, IDiffEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
export class EmbeddedCodeEditorWidget extends CodeEditorWidget {
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
opacity: 0.7;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 50% 50%;
|
||||
background-position: center;
|
||||
background-size: 11px 11px;
|
||||
}
|
||||
.monaco-editor.hc-black .insert-sign,
|
||||
.monaco-diff-editor.hc-black .insert-sign,
|
||||
|
||||
Reference in New Issue
Block a user