mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 01:28:26 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -198,7 +198,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
//#endregion
|
||||
|
||||
public readonly isSimpleWidget: boolean;
|
||||
private readonly _telemetryData: object | null;
|
||||
private readonly _telemetryData?: object;
|
||||
|
||||
private readonly _domElement: HTMLElement;
|
||||
private readonly _id: number;
|
||||
@@ -245,7 +245,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
this._decorationTypeKeysToIds = {};
|
||||
this._decorationTypeSubtypes = {};
|
||||
this.isSimpleWidget = codeEditorWidgetOptions.isSimpleWidget || false;
|
||||
this._telemetryData = codeEditorWidgetOptions.telemetryData || null;
|
||||
this._telemetryData = codeEditorWidgetOptions.telemetryData;
|
||||
|
||||
options = options || {};
|
||||
this._configuration = this._register(this._createConfiguration(options));
|
||||
@@ -396,7 +396,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
return this._modelData.model;
|
||||
}
|
||||
|
||||
public setModel(model: ITextModel | null = null): void {
|
||||
public setModel(_model: ITextModel | editorCommon.IDiffEditorModel | null = null): void {
|
||||
const model = <ITextModel | null>_model;
|
||||
if (this._modelData === null && model === null) {
|
||||
// Current model is the new model
|
||||
return;
|
||||
@@ -800,8 +801,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
const contributionsState: { [key: string]: any } = {};
|
||||
|
||||
const keys = Object.keys(this._contributions);
|
||||
for (let i = 0, len = keys.length; i < len; i++) {
|
||||
const id = keys[i];
|
||||
for (const id of keys) {
|
||||
const contribution = this._contributions[id];
|
||||
if (typeof contribution.saveViewState === 'function') {
|
||||
contributionsState[id] = contribution.saveViewState();
|
||||
@@ -817,12 +817,12 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
};
|
||||
}
|
||||
|
||||
public restoreViewState(s: editorCommon.ICodeEditorViewState): void {
|
||||
public restoreViewState(s: editorCommon.IEditorViewState | null): void {
|
||||
if (!this._modelData || !this._modelData.hasRealView) {
|
||||
return;
|
||||
}
|
||||
if (s && s.cursorState && s.viewState) {
|
||||
let codeEditorState = <editorCommon.ICodeEditorViewState>s;
|
||||
const codeEditorState = s as editorCommon.ICodeEditorViewState | null;
|
||||
if (codeEditorState && codeEditorState.cursorState && codeEditorState.viewState) {
|
||||
let cursorState = <any>codeEditorState.cursorState;
|
||||
if (Array.isArray(cursorState)) {
|
||||
this._modelData.cursor.restoreState(<editorCommon.ICursorState[]>cursorState);
|
||||
@@ -831,7 +831,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
this._modelData.cursor.restoreState([<editorCommon.ICursorState>cursorState]);
|
||||
}
|
||||
|
||||
let contributionsState = s.contributionsState || {};
|
||||
let contributionsState = codeEditorState.contributionsState || {};
|
||||
let keys = Object.keys(this._contributions);
|
||||
for (let i = 0, len = keys.length; i < len; i++) {
|
||||
let id = keys[i];
|
||||
@@ -841,11 +841,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
}
|
||||
}
|
||||
|
||||
const reducedState = this._modelData.viewModel.reduceRestoreState(s.viewState);
|
||||
const linesViewportData = this._modelData.viewModel.viewLayout.getLinesViewportDataAtScrollTop(reducedState.scrollTop);
|
||||
const startPosition = this._modelData.viewModel.coordinatesConverter.convertViewPositionToModelPosition(new Position(linesViewportData.startLineNumber, 1));
|
||||
const endPosition = this._modelData.viewModel.coordinatesConverter.convertViewPositionToModelPosition(new Position(linesViewportData.endLineNumber, 1));
|
||||
this._modelData.model.tokenizeViewport(startPosition.lineNumber, endPosition.lineNumber);
|
||||
const reducedState = this._modelData.viewModel.reduceRestoreState(codeEditorState.viewState);
|
||||
this._modelData.view.restoreState(reducedState);
|
||||
}
|
||||
}
|
||||
@@ -929,7 +925,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
|
||||
const action = this.getAction(handlerId);
|
||||
if (action) {
|
||||
Promise.resolve(action.run()).then(null, onUnexpectedError);
|
||||
Promise.resolve(action.run()).then(undefined, onUnexpectedError);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -950,7 +946,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
payload = payload || {};
|
||||
payload.source = source;
|
||||
this._instantiationService.invokeFunction((accessor) => {
|
||||
Promise.resolve(command.runEditorCommand(accessor, this, payload)).then(null, onUnexpectedError);
|
||||
Promise.resolve(command.runEditorCommand(accessor, this, payload)).then(undefined, onUnexpectedError);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
@@ -1282,11 +1278,11 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
return this._modelData.view.getOffsetForColumn(lineNumber, column);
|
||||
}
|
||||
|
||||
public render(): void {
|
||||
public render(forceRedraw: boolean = false): void {
|
||||
if (!this._modelData || !this._modelData.hasRealView) {
|
||||
return;
|
||||
}
|
||||
this._modelData.view.render(true, false);
|
||||
this._modelData.view.render(true, forceRedraw);
|
||||
}
|
||||
|
||||
public applyFontInfo(target: HTMLElement): void {
|
||||
@@ -1327,7 +1323,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
}));
|
||||
|
||||
listenersToRemove.push(cursor.onDidAttemptReadOnlyEdit(() => {
|
||||
this._onDidAttemptReadOnlyEdit.fire(void 0);
|
||||
this._onDidAttemptReadOnlyEdit.fire(undefined);
|
||||
}));
|
||||
|
||||
listenersToRemove.push(cursor.onDidChange((e: CursorStateChangedEvent) => {
|
||||
@@ -1506,7 +1502,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
/* __GDPR__FRAGMENT__
|
||||
"EditorTelemetryData" : {}
|
||||
*/
|
||||
public getTelemetryData(): { [key: string]: any; } | null {
|
||||
public getTelemetryData(): { [key: string]: any; } | undefined {
|
||||
return this._telemetryData;
|
||||
}
|
||||
|
||||
@@ -1766,11 +1762,11 @@ class CodeEditorWidgetFocusTracker extends Disposable {
|
||||
|
||||
this._register(this._domFocusTracker.onDidFocus(() => {
|
||||
this._hasFocus = true;
|
||||
this._onChange.fire(void 0);
|
||||
this._onChange.fire(undefined);
|
||||
}));
|
||||
this._register(this._domFocusTracker.onDidBlur(() => {
|
||||
this._hasFocus = false;
|
||||
this._onChange.fire(void 0);
|
||||
this._onChange.fire(undefined);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -1832,7 +1828,7 @@ registerThemingParticipant((theme, collector) => {
|
||||
|
||||
const unnecessaryForeground = theme.getColor(editorUnnecessaryCodeOpacity);
|
||||
if (unnecessaryForeground) {
|
||||
collector.addRule(`.${SHOW_UNUSED_ENABLED_CLASS} .monaco-editor .${ClassName.EditorUnnecessaryInlineDecoration} { opacity: ${unnecessaryForeground.rgba.a}; will-change: opacity; }`); // TODO@Ben: 'will-change: opacity' is a workaround for https://github.com/Microsoft/vscode/issues/52196
|
||||
collector.addRule(`.${SHOW_UNUSED_ENABLED_CLASS} .monaco-editor .${ClassName.EditorUnnecessaryInlineDecoration} { opacity: ${unnecessaryForeground.rgba.a}; }`);
|
||||
}
|
||||
|
||||
const unnecessaryBorder = theme.getColor(editorUnnecessaryCodeBorder);
|
||||
|
||||
@@ -369,15 +369,19 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._overviewDomElement.removeChild(this._originalOverviewRuler.getDomNode());
|
||||
this._originalOverviewRuler.dispose();
|
||||
}
|
||||
this._originalOverviewRuler = this.originalEditor.createOverviewRuler('original diffOverviewRuler');
|
||||
this._overviewDomElement.appendChild(this._originalOverviewRuler.getDomNode());
|
||||
if (this.originalEditor.hasModel()) {
|
||||
this._originalOverviewRuler = this.originalEditor.createOverviewRuler('original diffOverviewRuler')!;
|
||||
this._overviewDomElement.appendChild(this._originalOverviewRuler.getDomNode());
|
||||
}
|
||||
|
||||
if (this._modifiedOverviewRuler) {
|
||||
this._overviewDomElement.removeChild(this._modifiedOverviewRuler.getDomNode());
|
||||
this._modifiedOverviewRuler.dispose();
|
||||
}
|
||||
this._modifiedOverviewRuler = this.modifiedEditor.createOverviewRuler('modified diffOverviewRuler');
|
||||
this._overviewDomElement.appendChild(this._modifiedOverviewRuler.getDomNode());
|
||||
if (this.modifiedEditor.hasModel()) {
|
||||
this._modifiedOverviewRuler = this.modifiedEditor.createOverviewRuler('modified diffOverviewRuler')!;
|
||||
this._overviewDomElement.appendChild(this._modifiedOverviewRuler.getDomNode());
|
||||
}
|
||||
|
||||
this._layoutOverviewRulers();
|
||||
}
|
||||
@@ -597,8 +601,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
|
||||
public getModel(): editorCommon.IDiffEditorModel {
|
||||
return {
|
||||
original: this.originalEditor.getModel(),
|
||||
modified: this.modifiedEditor.getModel()
|
||||
original: this.originalEditor.getModel()!,
|
||||
modified: this.modifiedEditor.getModel()!
|
||||
};
|
||||
}
|
||||
|
||||
@@ -739,7 +743,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
|
||||
public restoreViewState(s: editorCommon.IDiffEditorViewState): void {
|
||||
if (s.original && s.original) {
|
||||
if (s.original && s.modified) {
|
||||
let diffEditorState = <editorCommon.IDiffEditorViewState>s;
|
||||
this.originalEditor.restoreViewState(diffEditorState.original);
|
||||
this.modifiedEditor.restoreViewState(diffEditorState.modified);
|
||||
@@ -964,7 +968,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
private _adjustOptionsForRightHandSide(options: editorOptions.IDiffEditorOptions): editorOptions.IEditorOptions {
|
||||
let result = this._adjustOptionsForSubEditor(options);
|
||||
result.revealHorizontalRightPadding = editorOptions.EDITOR_DEFAULTS.viewInfo.revealHorizontalRightPadding + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
|
||||
result.scrollbar.verticalHasArrows = false;
|
||||
result.scrollbar!.verticalHasArrows = false;
|
||||
result.extraEditorClassName = 'modified-in-monaco-diff-editor';
|
||||
return result;
|
||||
}
|
||||
@@ -1446,16 +1450,19 @@ abstract class ViewZonesComputer {
|
||||
// ---------------------------- END EMIT MINIMAL VIEW ZONES
|
||||
}
|
||||
|
||||
let ensureDomNode = (z: IMyViewZone) => {
|
||||
return {
|
||||
original: ViewZonesComputer._ensureDomNodes(result.original),
|
||||
modified: ViewZonesComputer._ensureDomNodes(result.modified),
|
||||
};
|
||||
}
|
||||
|
||||
private static _ensureDomNodes(zones: IMyViewZone[]): editorBrowser.IViewZone[] {
|
||||
return zones.map((z) => {
|
||||
if (!z.domNode) {
|
||||
z.domNode = createFakeLinesDiv();
|
||||
}
|
||||
};
|
||||
|
||||
result.original.forEach(ensureDomNode);
|
||||
result.modified.forEach(ensureDomNode);
|
||||
|
||||
return result;
|
||||
return <editorBrowser.IViewZone>z;
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract _createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion(): HTMLDivElement | null;
|
||||
@@ -1526,8 +1533,8 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
|
||||
private _disableSash: boolean;
|
||||
private _sash: Sash;
|
||||
private _sashRatio: number;
|
||||
private _sashPosition: number;
|
||||
private _sashRatio: number | null;
|
||||
private _sashPosition: number | null;
|
||||
private _startSashPosition: number;
|
||||
|
||||
constructor(dataSource: IDataSource, enableSplitViewResizing: boolean) {
|
||||
@@ -1556,7 +1563,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
}
|
||||
}
|
||||
|
||||
public layout(sashRatio: number = this._sashRatio): number {
|
||||
public layout(sashRatio: number | null = this._sashRatio): number {
|
||||
let w = this._dataSource.getWidth();
|
||||
let contentWidth = w - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
|
||||
|
||||
@@ -1586,7 +1593,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
}
|
||||
|
||||
private onSashDragStart(): void {
|
||||
this._startSashPosition = this._sashPosition;
|
||||
this._startSashPosition = this._sashPosition!;
|
||||
}
|
||||
|
||||
private onSashDrag(e: ISashEvent): void {
|
||||
@@ -1614,7 +1621,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
}
|
||||
|
||||
public getVerticalSashLeft(sash: Sash): number {
|
||||
return this._sashPosition;
|
||||
return this._sashPosition!;
|
||||
}
|
||||
|
||||
public getVerticalSashHeight(sash: Sash): number {
|
||||
@@ -1634,7 +1641,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
overviewZones: []
|
||||
};
|
||||
|
||||
let originalModel = originalEditor.getModel();
|
||||
let originalModel = originalEditor.getModel()!;
|
||||
|
||||
for (let i = 0, length = lineChanges.length; i < length; i++) {
|
||||
let lineChange = lineChanges[i];
|
||||
@@ -1694,7 +1701,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
overviewZones: []
|
||||
};
|
||||
|
||||
let modifiedModel = modifiedEditor.getModel();
|
||||
let modifiedModel = modifiedEditor.getModel()!;
|
||||
|
||||
for (let i = 0, length = lineChanges.length; i < length; i++) {
|
||||
let lineChange = lineChanges[i];
|
||||
@@ -1843,7 +1850,7 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
|
||||
overviewZones: []
|
||||
};
|
||||
|
||||
let modifiedModel = modifiedEditor.getModel();
|
||||
let modifiedModel = modifiedEditor.getModel()!;
|
||||
|
||||
for (let i = 0, length = lineChanges.length; i < length; i++) {
|
||||
let lineChange = lineChanges[i];
|
||||
@@ -1911,9 +1918,9 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
|
||||
constructor(lineChanges: editorCommon.ILineChange[], originalForeignVZ: IEditorWhitespace[], modifiedForeignVZ: IEditorWhitespace[], originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor, renderIndicators: boolean) {
|
||||
super(lineChanges, originalForeignVZ, modifiedForeignVZ);
|
||||
this.originalModel = originalEditor.getModel();
|
||||
this.originalModel = originalEditor.getModel()!;
|
||||
this.modifiedEditorConfiguration = modifiedEditor.getConfiguration();
|
||||
this.modifiedEditorTabSize = modifiedEditor.getModel().getOptions().tabSize;
|
||||
this.modifiedEditorTabSize = modifiedEditor.getModel()!.getOptions().tabSize;
|
||||
this.renderIndicators = renderIndicators;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ export class DiffReview extends Disposable {
|
||||
private readonly _content: FastDomNode<HTMLElement>;
|
||||
private readonly scrollbar: DomScrollableElement;
|
||||
private _diffs: Diff[];
|
||||
private _currentDiff: Diff;
|
||||
private _currentDiff: Diff | null;
|
||||
|
||||
constructor(diffEditor: DiffEditorWidget) {
|
||||
super();
|
||||
@@ -100,7 +100,7 @@ export class DiffReview extends Disposable {
|
||||
|
||||
this._actionBar.push(new Action('diffreview.close', nls.localize('label.close', "Close"), 'close-diff-review', true, () => {
|
||||
this.hide();
|
||||
return null;
|
||||
return Promise.resolve(null);
|
||||
}), { label: false, icon: true });
|
||||
|
||||
this.domNode = createFastDomNode(document.createElement('div'));
|
||||
@@ -200,7 +200,7 @@ export class DiffReview extends Disposable {
|
||||
}
|
||||
index = (this._diffs.length + currentIndex - 1);
|
||||
} else {
|
||||
index = this._findDiffIndex(this._diffEditor.getPosition());
|
||||
index = this._findDiffIndex(this._diffEditor.getPosition()!);
|
||||
}
|
||||
|
||||
if (this._diffs.length === 0) {
|
||||
@@ -233,7 +233,7 @@ export class DiffReview extends Disposable {
|
||||
}
|
||||
index = (currentIndex + 1);
|
||||
} else {
|
||||
index = this._findDiffIndex(this._diffEditor.getPosition());
|
||||
index = this._findDiffIndex(this._diffEditor.getPosition()!);
|
||||
}
|
||||
|
||||
if (this._diffs.length === 0) {
|
||||
@@ -253,7 +253,7 @@ export class DiffReview extends Disposable {
|
||||
let jumpToLineNumber = -1;
|
||||
let current = this._getCurrentFocusedRow();
|
||||
if (current) {
|
||||
let lineNumber = parseInt(current.getAttribute('data-line'), 10);
|
||||
let lineNumber = parseInt(current.getAttribute('data-line')!, 10);
|
||||
if (!isNaN(lineNumber)) {
|
||||
jumpToLineNumber = lineNumber;
|
||||
}
|
||||
@@ -299,7 +299,7 @@ export class DiffReview extends Disposable {
|
||||
return <HTMLElement>this.domNode.domNode.querySelector('.diff-review-row');
|
||||
}
|
||||
|
||||
private _getCurrentFocusedRow(): HTMLElement {
|
||||
private _getCurrentFocusedRow(): HTMLElement | null {
|
||||
let result = <HTMLElement>document.activeElement;
|
||||
if (result && /diff-review-row/.test(result.className)) {
|
||||
return result;
|
||||
@@ -530,8 +530,8 @@ export class DiffReview extends Disposable {
|
||||
const originalModel = this._diffEditor.getOriginalEditor().getModel();
|
||||
const modifiedModel = this._diffEditor.getModifiedEditor().getModel();
|
||||
|
||||
const originalModelOpts = originalModel.getOptions();
|
||||
const modifiedModelOpts = modifiedModel.getOptions();
|
||||
const originalModelOpts = originalModel!.getOptions();
|
||||
const modifiedModelOpts = modifiedModel!.getOptions();
|
||||
|
||||
if (!this._isVisible || !originalModel || !modifiedModel) {
|
||||
dom.clearNode(this._content.domNode);
|
||||
@@ -540,8 +540,7 @@ export class DiffReview extends Disposable {
|
||||
return;
|
||||
}
|
||||
|
||||
const pos = this._diffEditor.getPosition();
|
||||
const diffIndex = this._findDiffIndex(pos);
|
||||
const diffIndex = this._findDiffIndex(this._diffEditor.getPosition()!);
|
||||
|
||||
if (this._diffs[diffIndex] === this._currentDiff) {
|
||||
return;
|
||||
@@ -731,7 +730,7 @@ export class DiffReview extends Disposable {
|
||||
lineContent = nls.localize('blankLine', "blank");
|
||||
}
|
||||
|
||||
let ariaLabel: string;
|
||||
let ariaLabel: string = '';
|
||||
switch (type) {
|
||||
case DiffEntryType.Equal:
|
||||
ariaLabel = nls.localize('equalLine', "original {0}, modified {1}: {2}", originalLine, modifiedLine, lineContent);
|
||||
@@ -848,7 +847,7 @@ class DiffReviewPrev extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
function findFocusedDiffEditor(accessor: ServicesAccessor): DiffEditorWidget {
|
||||
function findFocusedDiffEditor(accessor: ServicesAccessor): DiffEditorWidget | null {
|
||||
const codeEditorService = accessor.get(ICodeEditorService);
|
||||
const diffEditors = codeEditorService.listDiffEditors();
|
||||
for (let i = 0, len = diffEditors.length; i < len; i++) {
|
||||
|
||||
Reference in New Issue
Block a user