提交 1ec1b9fe 编写于 作者: A Alex Dima

More fixes for #78168

上级 c250eb75
......@@ -50,8 +50,8 @@ interface IDomClassList {
const _manualClassList = new class implements IDomClassList {
private _lastStart: number;
private _lastEnd: number;
private _lastStart: number = -1;
private _lastEnd: number = -1;
private _findClassName(node: HTMLElement, className: string): void {
......
......@@ -12,8 +12,8 @@ export type ValueCallback<T = any> = (value: T | Promise<T>) => void;
export class DeferredPromise<T> {
private completeCallback: ValueCallback<T>;
private errorCallback: (err: any) => void;
private completeCallback!: ValueCallback<T>;
private errorCallback!: (err: any) => void;
public p: Promise<any>;
......
......@@ -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';
......@@ -156,17 +156,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 readonly originalEditor: CodeEditorWidget;
private readonly _originalDomNode: HTMLElement;
private readonly _originalEditorState: VisualEditorState;
private _originalOverviewRuler: editorBrowser.IOverviewRuler;
private _originalOverviewRuler: editorBrowser.IOverviewRuler | null;
private modifiedEditor: CodeEditorWidget;
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;
......@@ -182,7 +182,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;
......@@ -308,8 +308,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);
......@@ -317,7 +320,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
......@@ -397,10 +403,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._layoutOverviewRulers();
}
private _createLeftHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): void {
this.originalEditor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable));
private _createLeftHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
const editor = 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;
}
......@@ -417,21 +423,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;
}
......@@ -448,21 +456,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 {
......@@ -477,7 +487,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._beginUpdateDecorationsTimeout = -1;
}
window.clearInterval(this._measureDomElementToken);
if (this._measureDomElementToken) {
this._measureDomElementToken.dispose();
}
this._cleanViewZonesAndDecorations();
......@@ -813,6 +825,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) {
......@@ -914,7 +929,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 : []);
......
......@@ -784,7 +784,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
return ` (${kb.getLabel()})`;
}
private _buildFindPart(): HTMLElement {
private _buildDomNode(): void {
// Find input
this._findInput = this._register(new ContextScopedFindInput(null, this._contextViewProvider, {
width: FIND_INPUT_AREA_WIDTH,
......@@ -908,10 +908,6 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
findPart.appendChild(this._closeBtn.domNode);
return findPart;
}
private _buildReplacePart(): HTMLElement {
// Replace input
let replaceInput = document.createElement('div');
replaceInput.className = 'replace-input';
......@@ -977,16 +973,6 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
replacePart.appendChild(this._replaceBtn.domNode);
replacePart.appendChild(this._replaceAllBtn.domNode);
return replacePart;
}
private _buildDomNode(): void {
// Find part
let findPart = this._buildFindPart();
// Replace part
let replacePart = this._buildReplacePart();
// Toggle replace button
this._toggleReplaceBtn = this._register(new SimpleButton({
label: NLS_TOGGLE_REPLACE_MODE_BTN_LABEL,
......@@ -1014,10 +1000,6 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
this._domNode.appendChild(findPart);
this._domNode.appendChild(replacePart);
this._buildSash();
}
private _buildSash() {
this._resizeSash = new Sash(this._domNode, this, { orientation: Orientation.VERTICAL });
this._resized = false;
let originalWidth = FIND_WIDGET_INITIAL_WIDTH;
......
......@@ -79,6 +79,7 @@ export class FoldingController extends Disposable implements IEditorContribution
private cursorChangedScheduler: RunOnceScheduler | null;
private readonly localToDispose = this._register(new DisposableStore());
private mouseDownInfo: { lineNumber: number, iconClicked: boolean } | null;
constructor(
editor: ICodeEditor,
......@@ -340,8 +341,6 @@ export class FoldingController extends Disposable implements IEditorContribution
}
private mouseDownInfo: { lineNumber: number, iconClicked: boolean } | null;
private onEditorMouseDown(e: IEditorMouseEvent): void {
this.mouseDownInfo = null;
......
......@@ -39,14 +39,14 @@ export class ModesHoverController implements IEditorContribution {
get contentWidget(): ModesContentHoverWidget {
if (!this._contentWidget) {
this._createHoverWidget();
this._createHoverWidgets();
}
return this._contentWidget!;
}
get glyphWidget(): ModesGlyphHoverWidget {
if (!this._glyphWidget) {
this._createHoverWidget();
this._createHoverWidgets();
}
return this._glyphWidget!;
}
......@@ -198,7 +198,7 @@ export class ModesHoverController implements IEditorContribution {
}
private _hideWidgets(): void {
if (!this._contentWidget || (this._isMouseDown && this._hoverClicked && this._contentWidget.isColorPickerVisible())) {
if (!this._glyphWidget || !this._contentWidget || (this._isMouseDown && this._hoverClicked && this._contentWidget.isColorPickerVisible())) {
return;
}
......@@ -206,7 +206,7 @@ export class ModesHoverController implements IEditorContribution {
this._contentWidget.hide();
}
private _createHoverWidget() {
private _createHoverWidgets() {
this._contentWidget = new ModesContentHoverWidget(this._editor, this._markerDecorationsService, this._themeService, this._keybindingService, this._modeService, this._openerService);
this._glyphWidget = new ModesGlyphHoverWidget(this._editor, this._modeService, this._openerService);
}
......
......@@ -73,6 +73,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
this._editor.addContentWidget(this);
this._showAtPosition = null;
this._showAtRange = null;
this._stoleFocus = false;
}
public getId(): string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册