mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 19:48:37 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -14,10 +14,9 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { CommonCodeEditor } from 'vs/editor/common/commonCodeEditor';
|
||||
import { CommonEditorConfiguration } from 'vs/editor/common/config/commonEditorConfig';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { EditorAction } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { EditorAction, EditorExtensionsRegistry, IEditorContributionCtor } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { Configuration } from 'vs/editor/browser/config/configuration';
|
||||
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { View, IOverlayWidgetData, IContentWidgetData } from 'vs/editor/browser/view/viewImpl';
|
||||
@@ -27,12 +26,12 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { InternalEditorAction } from 'vs/editor/common/editorAction';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IEditorWhitespace } from 'vs/editor/common/viewLayout/whitespaceComputer';
|
||||
import { CoreEditorCommand } from 'vs/editor/common/controller/coreCommands';
|
||||
import { CoreEditorCommand } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { editorErrorForeground, editorErrorBorder, editorWarningForeground, editorWarningBorder, editorInfoBorder, editorInfoForeground } from 'vs/editor/common/view/editorColorRegistry';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { ClassName } from 'vs/editor/common/model/intervalTree';
|
||||
|
||||
export abstract class CodeEditorWidget extends CommonCodeEditor implements editorBrowser.ICodeEditor {
|
||||
|
||||
@@ -141,7 +140,7 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
this._codeEditorService.addCodeEditor(this);
|
||||
}
|
||||
|
||||
protected abstract _getContributions(): editorBrowser.IEditorContributionCtor[];
|
||||
protected abstract _getContributions(): IEditorContributionCtor[];
|
||||
protected abstract _getActions(): EditorAction[];
|
||||
|
||||
protected _createConfiguration(options: IEditorOptions): CommonEditorConfiguration {
|
||||
@@ -169,14 +168,6 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
return this._view.domNode.domNode;
|
||||
}
|
||||
|
||||
public getCompletelyVisibleLinesRangeInViewport(): Range {
|
||||
if (!this.hasView) {
|
||||
return null;
|
||||
}
|
||||
const viewRange = this.viewModel.getCompletelyVisibleViewRange();
|
||||
return this.viewModel.coordinatesConverter.convertViewRangeToModelRange(viewRange);
|
||||
}
|
||||
|
||||
public delegateVerticalScrollbarMouseDown(browserEvent: IMouseEvent): void {
|
||||
if (!this.hasView) {
|
||||
return;
|
||||
@@ -292,36 +283,6 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
}
|
||||
}
|
||||
|
||||
public getWhitespaces(): IEditorWhitespace[] {
|
||||
if (!this.hasView) {
|
||||
return [];
|
||||
}
|
||||
return this.viewModel.viewLayout.getWhitespaces();
|
||||
}
|
||||
|
||||
private _getVerticalOffsetForPosition(modelLineNumber: number, modelColumn: number): number {
|
||||
let modelPosition = this.model.validatePosition({
|
||||
lineNumber: modelLineNumber,
|
||||
column: modelColumn
|
||||
});
|
||||
let viewPosition = this.viewModel.coordinatesConverter.convertModelPositionToViewPosition(modelPosition);
|
||||
return this.viewModel.viewLayout.getVerticalOffsetForLineNumber(viewPosition.lineNumber);
|
||||
}
|
||||
|
||||
public getTopForLineNumber(lineNumber: number): number {
|
||||
if (!this.hasView) {
|
||||
return -1;
|
||||
}
|
||||
return this._getVerticalOffsetForPosition(lineNumber, 1);
|
||||
}
|
||||
|
||||
public getTopForPosition(lineNumber: number, column: number): number {
|
||||
if (!this.hasView) {
|
||||
return -1;
|
||||
}
|
||||
return this._getVerticalOffsetForPosition(lineNumber, column);
|
||||
}
|
||||
|
||||
public getTargetAtClientPoint(clientX: number, clientY: number): editorBrowser.IMouseTarget {
|
||||
if (!this.hasView) {
|
||||
return null;
|
||||
@@ -361,19 +322,6 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
this._view.render(true, false);
|
||||
}
|
||||
|
||||
public setHiddenAreas(ranges: IRange[]): void {
|
||||
if (this.viewModel) {
|
||||
this.viewModel.setHiddenAreas(ranges.map(r => Range.lift(r)));
|
||||
}
|
||||
}
|
||||
|
||||
public setAriaActiveDescendant(id: string): void {
|
||||
if (!this.hasView) {
|
||||
return;
|
||||
}
|
||||
this._view.setAriaActiveDescendant(id);
|
||||
}
|
||||
|
||||
public applyFontInfo(target: HTMLElement): void {
|
||||
Configuration.applyFontInfoSlow(target, this._configuration.editor.fontInfo);
|
||||
}
|
||||
@@ -477,6 +425,18 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
}
|
||||
|
||||
// END decorations
|
||||
|
||||
protected _triggerEditorCommand(source: string, handlerId: string, payload: any): boolean {
|
||||
const command = EditorExtensionsRegistry.getEditorCommand(handlerId);
|
||||
if (command) {
|
||||
payload = payload || {};
|
||||
payload.source = source;
|
||||
TPromise.as(command.runEditorCommand(null, this, payload)).done(null, onUnexpectedError);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class CodeEditorWidgetFocusTracker extends Disposable {
|
||||
@@ -493,14 +453,14 @@ class CodeEditorWidgetFocusTracker extends Disposable {
|
||||
this._hasFocus = false;
|
||||
this._domFocusTracker = this._register(dom.trackFocus(domElement));
|
||||
|
||||
this._domFocusTracker.addFocusListener(() => {
|
||||
this._register(this._domFocusTracker.onDidFocus(() => {
|
||||
this._hasFocus = true;
|
||||
this._onChange.fire(void 0);
|
||||
});
|
||||
this._domFocusTracker.addBlurListener(() => {
|
||||
}));
|
||||
this._register(this._domFocusTracker.onDidBlur(() => {
|
||||
this._hasFocus = false;
|
||||
this._onChange.fire(void 0);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public hasFocus(): boolean {
|
||||
@@ -508,7 +468,7 @@ class CodeEditorWidgetFocusTracker extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
const squigglyStart = encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' height='3' width='6'><g fill='`);
|
||||
const squigglyStart = encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 3' enable-background='new 0 0 6 3' height='3' width='6'><g fill='`);
|
||||
const squigglyEnd = encodeURIComponent(`'><polygon points='5.5,0 2.5,3 1.1,3 4.1,0'/><polygon points='4,0 6,2 6,0.6 5.4,0'/><polygon points='0,2 1,3 2.4,3 0,0.6'/></g></svg>`);
|
||||
|
||||
function getSquigglySVGData(color: Color) {
|
||||
@@ -518,28 +478,28 @@ function getSquigglySVGData(color: Color) {
|
||||
registerThemingParticipant((theme, collector) => {
|
||||
let errorBorderColor = theme.getColor(editorErrorBorder);
|
||||
if (errorBorderColor) {
|
||||
collector.addRule(`.monaco-editor .errorsquiggly { border-bottom: 4px double ${errorBorderColor}; }`);
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorErrorDecoration} { border-bottom: 4px double ${errorBorderColor}; }`);
|
||||
}
|
||||
let errorForeground = theme.getColor(editorErrorForeground);
|
||||
if (errorForeground) {
|
||||
collector.addRule(`.monaco-editor .errorsquiggly { background: url("data:image/svg+xml,${getSquigglySVGData(errorForeground)}") repeat-x bottom left; }`);
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorErrorDecoration} { background: url("data:image/svg+xml;utf8,${getSquigglySVGData(errorForeground)}") repeat-x bottom left; }`);
|
||||
}
|
||||
|
||||
let warningBorderColor = theme.getColor(editorWarningBorder);
|
||||
if (warningBorderColor) {
|
||||
collector.addRule(`.monaco-editor .warningsquiggly { border-bottom: 4px double ${warningBorderColor}; }`);
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorWarningDecoration} { border-bottom: 4px double ${warningBorderColor}; }`);
|
||||
}
|
||||
let warningForeground = theme.getColor(editorWarningForeground);
|
||||
if (warningForeground) {
|
||||
collector.addRule(`.monaco-editor .warningsquiggly { background: url("data:image/svg+xml;utf8,${getSquigglySVGData(warningForeground)}") repeat-x bottom left; }`);
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorWarningDecoration} { background: url("data:image/svg+xml;utf8,${getSquigglySVGData(warningForeground)}") repeat-x bottom left; }`);
|
||||
}
|
||||
|
||||
let infoBorderColor = theme.getColor(editorInfoBorder);
|
||||
if (warningBorderColor) {
|
||||
collector.addRule(`.monaco-editor .infosquiggly { border-bottom: 4px double ${infoBorderColor}; }`);
|
||||
if (infoBorderColor) {
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorInfoDecoration} { border-bottom: 4px double ${infoBorderColor}; }`);
|
||||
}
|
||||
let infoForeground = theme.getColor(editorInfoForeground);
|
||||
if (warningForeground) {
|
||||
collector.addRule(`.monaco-editor .infosquiggly { background: url("data:image/svg+xml;utf8,${getSquigglySVGData(infoForeground)}") repeat-x bottom left; }`);
|
||||
if (infoForeground) {
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorInfoDecoration} { background: url("data:image/svg+xml;utf8,${getSquigglySVGData(infoForeground)}") repeat-x bottom left; }`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { ISashEvent, IVerticalSashLayoutProvider, Sash } 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/common/services/codeEditorService';
|
||||
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';
|
||||
@@ -28,7 +28,7 @@ import { ViewLineToken } from 'vs/editor/common/core/viewLineToken';
|
||||
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 } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { InlineDecoration, InlineDecorationType } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { ColorId, MetadataConsts, FontStyle } from 'vs/editor/common/modes';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
@@ -137,9 +137,9 @@ let DIFF_EDITOR_ID = 0;
|
||||
|
||||
export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffEditor {
|
||||
|
||||
private static ONE_OVERVIEW_WIDTH = 15;
|
||||
public static ENTIRE_DIFF_OVERVIEW_WIDTH = 30;
|
||||
private static UPDATE_DIFF_DECORATIONS_DELAY = 200; // ms
|
||||
private static readonly ONE_OVERVIEW_WIDTH = 15;
|
||||
public static readonly ENTIRE_DIFF_OVERVIEW_WIDTH = 30;
|
||||
private static readonly UPDATE_DIFF_DECORATIONS_DELAY = 200; // ms
|
||||
|
||||
private readonly _onDidDispose: Emitter<void> = this._register(new Emitter<void>());
|
||||
public readonly onDidDispose: Event<void> = this._onDidDispose.event;
|
||||
@@ -462,10 +462,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return instantiationService.createInstance(CodeEditor, container, options);
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._codeEditorService.removeDiffEditor(this);
|
||||
|
||||
@@ -567,10 +563,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
}
|
||||
|
||||
public getValue(options: { preserveBOM: boolean; lineEnding: string; } = null): string {
|
||||
return this.modifiedEditor.getValue(options);
|
||||
}
|
||||
|
||||
public getModel(): editorCommon.IDiffEditorModel {
|
||||
return {
|
||||
original: this.originalEditor.getModel(),
|
||||
@@ -701,18 +693,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this.modifiedEditor.revealRangeAtTop(range, scrollType);
|
||||
}
|
||||
|
||||
public getActions(): editorCommon.IEditorAction[] {
|
||||
return this.modifiedEditor.getActions();
|
||||
}
|
||||
|
||||
public getSupportedActions(): editorCommon.IEditorAction[] {
|
||||
return this.modifiedEditor.getSupportedActions();
|
||||
}
|
||||
|
||||
public getAction(id: string): editorCommon.IEditorAction {
|
||||
return this.modifiedEditor.getAction(id);
|
||||
}
|
||||
|
||||
public saveViewState(): editorCommon.IDiffEditorViewState {
|
||||
let originalViewState = this.originalEditor.saveViewState();
|
||||
let modifiedViewState = this.modifiedEditor.saveViewState();
|
||||
@@ -919,7 +903,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
|
||||
private _adjustOptionsForSubEditor(options: editorOptions.IDiffEditorOptions): editorOptions.IDiffEditorOptions {
|
||||
let clonedOptions: editorOptions.IDiffEditorOptions = objects.clone(options || {});
|
||||
let clonedOptions: editorOptions.IDiffEditorOptions = objects.deepClone(options || {});
|
||||
clonedOptions.inDiffEditor = true;
|
||||
clonedOptions.wordWrap = 'off';
|
||||
clonedOptions.wordWrapMinified = false;
|
||||
@@ -1131,7 +1115,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return originalEquivalentLineNumber + lineChangeOriginalLength - lineChangeModifiedLength + delta;
|
||||
}
|
||||
|
||||
public getDiffLineInformationForOriginal(lineNumber: number): editorCommon.IDiffLineInformation {
|
||||
public getDiffLineInformationForOriginal(lineNumber: number): editorBrowser.IDiffLineInformation {
|
||||
if (!this._lineChanges) {
|
||||
// Cannot answer that which I don't know
|
||||
return null;
|
||||
@@ -1141,7 +1125,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
};
|
||||
}
|
||||
|
||||
public getDiffLineInformationForModified(lineNumber: number): editorCommon.IDiffLineInformation {
|
||||
public getDiffLineInformationForModified(lineNumber: number): editorBrowser.IDiffLineInformation {
|
||||
if (!this._lineChanges) {
|
||||
// Cannot answer that which I don't know
|
||||
return null;
|
||||
@@ -1516,10 +1500,10 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
this._sash.disable();
|
||||
}
|
||||
|
||||
this._sash.addListener('start', () => this.onSashDragStart());
|
||||
this._sash.addListener('change', (e: ISashEvent) => this.onSashDrag(e));
|
||||
this._sash.addListener('end', () => this.onSashDragEnd());
|
||||
this._sash.addListener('reset', () => this.onSashReset());
|
||||
this._sash.onDidStart(() => this.onSashDragStart());
|
||||
this._sash.onDidChange((e: ISashEvent) => this.onSashDrag(e));
|
||||
this._sash.onDidEnd(() => this.onSashDragEnd());
|
||||
this._sash.onDidReset(() => this.onSashReset());
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
@@ -1938,7 +1922,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
decorations.push(new InlineDecoration(
|
||||
new Range(charChange.originalStartLineNumber, charChange.originalStartColumn, charChange.originalEndLineNumber, charChange.originalEndColumn),
|
||||
'char-delete',
|
||||
false
|
||||
InlineDecorationType.Regular
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -2056,4 +2040,4 @@ registerThemingParticipant((theme, collector) => {
|
||||
if (shadow) {
|
||||
collector.addRule(`.monaco-diff-editor.side-by-side .editor.modified { box-shadow: -6px 0 5px -5px ${shadow}; }`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'vs/base/common/assert';
|
||||
import { EventEmitter } from 'vs/base/common/eventEmitter';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ICommonDiffEditor, ILineChange, ScrollType } from 'vs/editor/common/editorCommon';
|
||||
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 {
|
||||
rhs: boolean;
|
||||
@@ -32,73 +34,69 @@ var defaultOptions: Options = {
|
||||
/**
|
||||
* Create a new diff navigator for the provided diff editor.
|
||||
*/
|
||||
export class DiffNavigator extends EventEmitter {
|
||||
export class DiffNavigator {
|
||||
|
||||
public static Events = {
|
||||
UPDATED: 'navigation.updated'
|
||||
};
|
||||
private readonly _editor: IDiffEditor;
|
||||
private readonly _options: Options;
|
||||
private readonly _disposables: IDisposable[];
|
||||
private readonly _onDidUpdate = new Emitter<this>();
|
||||
|
||||
readonly onDidUpdate: Event<this> = this._onDidUpdate.event;
|
||||
|
||||
private editor: ICommonDiffEditor;
|
||||
private options: Options;
|
||||
private disposed: boolean;
|
||||
private toUnbind: IDisposable[];
|
||||
|
||||
private revealFirst: boolean;
|
||||
private nextIdx: number;
|
||||
private ranges: IDiffRange[];
|
||||
private ignoreSelectionChange: boolean;
|
||||
public revealFirst: boolean;
|
||||
|
||||
constructor(editor: ICommonDiffEditor, options: Options = {}) {
|
||||
super([
|
||||
DiffNavigator.Events.UPDATED
|
||||
]);
|
||||
this.editor = editor;
|
||||
this.options = objects.mixin(options, defaultOptions, false);
|
||||
constructor(editor: IDiffEditor, options: Options = {}) {
|
||||
this._editor = editor;
|
||||
this._options = objects.mixin(options, defaultOptions, false);
|
||||
|
||||
this.disposed = false;
|
||||
this.toUnbind = [];
|
||||
this._disposables = [];
|
||||
|
||||
this.nextIdx = -1;
|
||||
this.ranges = [];
|
||||
this.ignoreSelectionChange = false;
|
||||
this.revealFirst = this.options.alwaysRevealFirst;
|
||||
this.revealFirst = this._options.alwaysRevealFirst;
|
||||
|
||||
// hook up to diff editor for diff, disposal, and caret move
|
||||
this.toUnbind.push(this.editor.onDidDispose(() => this.dispose()));
|
||||
this.toUnbind.push(this.editor.onDidUpdateDiff(() => this.onDiffUpdated()));
|
||||
this._disposables.push(this._editor.onDidDispose(() => this.dispose()));
|
||||
this._disposables.push(this._editor.onDidUpdateDiff(() => this._onDiffUpdated()));
|
||||
|
||||
if (this.options.followsCaret) {
|
||||
this.toUnbind.push(this.editor.getModifiedEditor().onDidChangeCursorPosition((e: ICursorPositionChangedEvent) => {
|
||||
if (this._options.followsCaret) {
|
||||
this._disposables.push(this._editor.getModifiedEditor().onDidChangeCursorPosition((e: ICursorPositionChangedEvent) => {
|
||||
if (this.ignoreSelectionChange) {
|
||||
return;
|
||||
}
|
||||
this.nextIdx = -1;
|
||||
}));
|
||||
}
|
||||
if (this.options.alwaysRevealFirst) {
|
||||
this.toUnbind.push(this.editor.getModifiedEditor().onDidChangeModel((e) => {
|
||||
if (this._options.alwaysRevealFirst) {
|
||||
this._disposables.push(this._editor.getModifiedEditor().onDidChangeModel((e) => {
|
||||
this.revealFirst = true;
|
||||
}));
|
||||
}
|
||||
|
||||
// init things
|
||||
this.init();
|
||||
this._init();
|
||||
}
|
||||
|
||||
private init(): void {
|
||||
var changes = this.editor.getLineChanges();
|
||||
private _init(): void {
|
||||
var changes = this._editor.getLineChanges();
|
||||
if (!changes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private onDiffUpdated(): void {
|
||||
this.init();
|
||||
private _onDiffUpdated(): void {
|
||||
this._init();
|
||||
|
||||
this.compute(this.editor.getLineChanges());
|
||||
this._compute(this._editor.getLineChanges());
|
||||
if (this.revealFirst) {
|
||||
// Only reveal first on first non-null changes
|
||||
if (this.editor.getLineChanges() !== null) {
|
||||
if (this._editor.getLineChanges() !== null) {
|
||||
this.revealFirst = false;
|
||||
this.nextIdx = -1;
|
||||
this.next();
|
||||
@@ -106,7 +104,7 @@ export class DiffNavigator extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
private compute(lineChanges: ILineChange[]): void {
|
||||
private _compute(lineChanges: ILineChange[]): void {
|
||||
|
||||
// new ranges
|
||||
this.ranges = [];
|
||||
@@ -115,7 +113,7 @@ export class DiffNavigator extends EventEmitter {
|
||||
// create ranges from changes
|
||||
lineChanges.forEach((lineChange) => {
|
||||
|
||||
if (!this.options.ignoreCharChanges && lineChange.charChanges) {
|
||||
if (!this._options.ignoreCharChanges && lineChange.charChanges) {
|
||||
|
||||
lineChange.charChanges.forEach((charChange) => {
|
||||
this.ranges.push({
|
||||
@@ -147,13 +145,12 @@ export class DiffNavigator extends EventEmitter {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
this.emit(DiffNavigator.Events.UPDATED, {});
|
||||
this._onDidUpdate.fire(this);
|
||||
}
|
||||
|
||||
private initIdx(fwd: boolean): void {
|
||||
private _initIdx(fwd: boolean): void {
|
||||
var found = false;
|
||||
var position = this.editor.getPosition();
|
||||
var position = this._editor.getPosition();
|
||||
for (var i = 0, len = this.ranges.length; i < len && !found; i++) {
|
||||
var range = this.ranges[i].range;
|
||||
if (position.isBeforeOrEqual(range.getStartPosition())) {
|
||||
@@ -170,7 +167,7 @@ export class DiffNavigator extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
private move(fwd: boolean): void {
|
||||
private _move(fwd: boolean): void {
|
||||
assert.ok(!this.disposed, 'Illegal State - diff navigator has been disposed');
|
||||
|
||||
if (!this.canNavigate()) {
|
||||
@@ -178,7 +175,7 @@ export class DiffNavigator extends EventEmitter {
|
||||
}
|
||||
|
||||
if (this.nextIdx === -1) {
|
||||
this.initIdx(fwd);
|
||||
this._initIdx(fwd);
|
||||
|
||||
} else if (fwd) {
|
||||
this.nextIdx += 1;
|
||||
@@ -196,31 +193,30 @@ export class DiffNavigator extends EventEmitter {
|
||||
this.ignoreSelectionChange = true;
|
||||
try {
|
||||
var pos = info.range.getStartPosition();
|
||||
this.editor.setPosition(pos);
|
||||
this.editor.revealPositionInCenter(pos, ScrollType.Smooth);
|
||||
this._editor.setPosition(pos);
|
||||
this._editor.revealPositionInCenter(pos, ScrollType.Smooth);
|
||||
} finally {
|
||||
this.ignoreSelectionChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
public canNavigate(): boolean {
|
||||
canNavigate(): boolean {
|
||||
return this.ranges && this.ranges.length > 0;
|
||||
}
|
||||
|
||||
public next(): void {
|
||||
this.move(true);
|
||||
next(): void {
|
||||
this._move(true);
|
||||
}
|
||||
|
||||
public previous(): void {
|
||||
this.move(false);
|
||||
previous(): void {
|
||||
this._move(false);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.toUnbind = dispose(this.toUnbind);
|
||||
dispose(): void {
|
||||
dispose(this._disposables);
|
||||
this._disposables.length = 0;
|
||||
this._onDidUpdate.dispose();
|
||||
this.ranges = null;
|
||||
this.disposed = true;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,10 @@ 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 { Action } from 'vs/base/common/actions';
|
||||
import { editorAction, EditorAction, ServicesAccessor } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { registerEditorAction, EditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
const DIFF_LINES_PADDING = 3;
|
||||
|
||||
@@ -763,7 +764,6 @@ registerThemingParticipant((theme, collector) => {
|
||||
}
|
||||
});
|
||||
|
||||
@editorAction
|
||||
class DiffReviewNext extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -778,7 +778,7 @@ class DiffReviewNext extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
const diffEditor = findFocusedDiffEditor(accessor);
|
||||
if (diffEditor) {
|
||||
diffEditor.diffReviewNext();
|
||||
@@ -786,7 +786,6 @@ class DiffReviewNext extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class DiffReviewPrev extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -801,7 +800,7 @@ class DiffReviewPrev extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
const diffEditor = findFocusedDiffEditor(accessor);
|
||||
if (diffEditor) {
|
||||
diffEditor.diffReviewPrev();
|
||||
@@ -820,3 +819,6 @@ function findFocusedDiffEditor(accessor: ServicesAccessor): DiffEditorWidget {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
registerEditorAction(DiffReviewNext);
|
||||
registerEditorAction(DiffReviewPrev);
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as objects from 'vs/base/common/objects';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { CodeEditor } from 'vs/editor/browser/codeEditor';
|
||||
import { IConfigurationChangedEvent, IEditorOptions, IDiffEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
@@ -98,4 +98,4 @@ export class EmbeddedDiffEditorWidget extends DiffEditorWidget {
|
||||
objects.mixin(this._overwriteOptions, newOptions, true);
|
||||
super.updateOptions(this._overwriteOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user