Skip to content

Commit 1ec1b9f

Browse files
committed
More fixes for microsoft#78168
1 parent c250eb7 commit 1ec1b9f

7 files changed

Lines changed: 50 additions & 53 deletions

File tree

src/vs/base/browser/dom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ interface IDomClassList {
5050

5151
const _manualClassList = new class implements IDomClassList {
5252

53-
private _lastStart: number;
54-
private _lastEnd: number;
53+
private _lastStart: number = -1;
54+
private _lastEnd: number = -1;
5555

5656
private _findClassName(node: HTMLElement, className: string): void {
5757

src/vs/base/test/common/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export type ValueCallback<T = any> = (value: T | Promise<T>) => void;
1212

1313
export class DeferredPromise<T> {
1414

15-
private completeCallback: ValueCallback<T>;
16-
private errorCallback: (err: any) => void;
15+
private completeCallback!: ValueCallback<T>;
16+
private errorCallback!: (err: any) => void;
1717

1818
public p: Promise<any>;
1919

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
88
import * as dom from 'vs/base/browser/dom';
99
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
1010
import { ISashEvent, IVerticalSashLayoutProvider, Sash, SashState } from 'vs/base/browser/ui/sash/sash';
11-
import { RunOnceScheduler } from 'vs/base/common/async';
11+
import { RunOnceScheduler, IntervalTimer } from 'vs/base/common/async';
1212
import { Color } from 'vs/base/common/color';
1313
import { Emitter, Event } from 'vs/base/common/event';
1414
import { Disposable } from 'vs/base/common/lifecycle';
@@ -156,17 +156,17 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
156156
private _width: number;
157157
private _height: number;
158158
private _reviewHeight: number;
159-
private readonly _measureDomElementToken: number;
159+
private readonly _measureDomElementToken: IntervalTimer | null;
160160

161-
private originalEditor: CodeEditorWidget;
161+
private readonly originalEditor: CodeEditorWidget;
162162
private readonly _originalDomNode: HTMLElement;
163163
private readonly _originalEditorState: VisualEditorState;
164-
private _originalOverviewRuler: editorBrowser.IOverviewRuler;
164+
private _originalOverviewRuler: editorBrowser.IOverviewRuler | null;
165165

166-
private modifiedEditor: CodeEditorWidget;
166+
private readonly modifiedEditor: CodeEditorWidget;
167167
private readonly _modifiedDomNode: HTMLElement;
168168
private readonly _modifiedEditorState: VisualEditorState;
169-
private _modifiedOverviewRuler: editorBrowser.IOverviewRuler;
169+
private _modifiedOverviewRuler: editorBrowser.IOverviewRuler | null;
170170

171171
private _currentlyChangingViewZones: boolean;
172172
private _beginUpdateDecorationsTimeout: number;
@@ -182,7 +182,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
182182
private _renderSideBySide: boolean;
183183
private _renderIndicators: boolean;
184184
private _enableSplitViewResizing: boolean;
185-
private _strategy: IDiffEditorWidgetStyle;
185+
private _strategy!: IDiffEditorWidgetStyle;
186186

187187
private readonly _updateDecorationsRunner: RunOnceScheduler;
188188

@@ -308,16 +308,22 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
308308
rightServices.set(IContextKeyService, rightContextKeyService);
309309
const rightScopedInstantiationService = instantiationService.createChild(rightServices);
310310

311-
this._createLeftHandSideEditor(options, leftScopedInstantiationService);
312-
this._createRightHandSideEditor(options, rightScopedInstantiationService);
311+
this.originalEditor = this._createLeftHandSideEditor(options, leftScopedInstantiationService);
312+
this.modifiedEditor = this._createRightHandSideEditor(options, rightScopedInstantiationService);
313+
314+
this._originalOverviewRuler = null;
315+
this._modifiedOverviewRuler = null;
313316

314317
this._reviewPane = new DiffReview(this);
315318
this._containerDomElement.appendChild(this._reviewPane.domNode.domNode);
316319
this._containerDomElement.appendChild(this._reviewPane.shadow.domNode);
317320
this._containerDomElement.appendChild(this._reviewPane.actionBarContainer.domNode);
318321

319322
if (options.automaticLayout) {
320-
this._measureDomElementToken = window.setInterval(() => this._measureDomElement(false), 100);
323+
this._measureDomElementToken = new IntervalTimer();
324+
this._measureDomElementToken.cancelAndSet(() => this._measureDomElement(false), 100);
325+
} else {
326+
this._measureDomElementToken = null;
321327
}
322328

323329
// enableSplitViewResizing
@@ -397,10 +403,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
397403
this._layoutOverviewRulers();
398404
}
399405

400-
private _createLeftHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): void {
401-
this.originalEditor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable));
406+
private _createLeftHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
407+
const editor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable));
402408

403-
this._register(this.originalEditor.onDidScrollChange((e) => {
409+
this._register(editor.onDidScrollChange((e) => {
404410
if (this._isHandlingScrollEvent) {
405411
return;
406412
}
@@ -417,21 +423,23 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
417423
this._layoutOverviewViewport();
418424
}));
419425

420-
this._register(this.originalEditor.onDidChangeViewZones(() => {
426+
this._register(editor.onDidChangeViewZones(() => {
421427
this._onViewZonesChanged();
422428
}));
423429

424-
this._register(this.originalEditor.onDidChangeModelContent(() => {
430+
this._register(editor.onDidChangeModelContent(() => {
425431
if (this._isVisible) {
426432
this._beginUpdateDecorationsSoon();
427433
}
428434
}));
435+
436+
return editor;
429437
}
430438

431-
private _createRightHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): void {
432-
this.modifiedEditor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options));
439+
private _createRightHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
440+
const editor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options));
433441

434-
this._register(this.modifiedEditor.onDidScrollChange((e) => {
442+
this._register(editor.onDidScrollChange((e) => {
435443
if (this._isHandlingScrollEvent) {
436444
return;
437445
}
@@ -448,21 +456,23 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
448456
this._layoutOverviewViewport();
449457
}));
450458

451-
this._register(this.modifiedEditor.onDidChangeViewZones(() => {
459+
this._register(editor.onDidChangeViewZones(() => {
452460
this._onViewZonesChanged();
453461
}));
454462

455-
this._register(this.modifiedEditor.onDidChangeConfiguration((e) => {
456-
if (e.fontInfo && this.modifiedEditor.getModel()) {
463+
this._register(editor.onDidChangeConfiguration((e) => {
464+
if (e.fontInfo && editor.getModel()) {
457465
this._onViewZonesChanged();
458466
}
459467
}));
460468

461-
this._register(this.modifiedEditor.onDidChangeModelContent(() => {
469+
this._register(editor.onDidChangeModelContent(() => {
462470
if (this._isVisible) {
463471
this._beginUpdateDecorationsSoon();
464472
}
465473
}));
474+
475+
return editor;
466476
}
467477

468478
protected _createInnerEditor(instantiationService: IInstantiationService, container: HTMLElement, options: editorOptions.IEditorOptions): CodeEditorWidget {
@@ -477,7 +487,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
477487
this._beginUpdateDecorationsTimeout = -1;
478488
}
479489

480-
window.clearInterval(this._measureDomElementToken);
490+
if (this._measureDomElementToken) {
491+
this._measureDomElementToken.dispose();
492+
}
481493

482494
this._cleanViewZonesAndDecorations();
483495

@@ -813,6 +825,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
813825
}
814826

815827
private _layoutOverviewRulers(): void {
828+
if (!this._originalOverviewRuler || !this._modifiedOverviewRuler) {
829+
return;
830+
}
816831
let freeSpace = DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH - 2 * DiffEditorWidget.ONE_OVERVIEW_WIDTH;
817832
let layoutInfo = this.modifiedEditor.getLayoutInfo();
818833
if (layoutInfo) {
@@ -914,7 +929,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
914929
}
915930

916931
private _updateDecorations(): void {
917-
if (!this.originalEditor.getModel() || !this.modifiedEditor.getModel()) {
932+
if (!this.originalEditor.getModel() || !this.modifiedEditor.getModel() || !this._originalOverviewRuler || !this._modifiedOverviewRuler) {
918933
return;
919934
}
920935
const lineChanges = (this._diffComputationResult ? this._diffComputationResult.changes : []);

src/vs/editor/contrib/find/findWidget.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
784784
return ` (${kb.getLabel()})`;
785785
}
786786

787-
private _buildFindPart(): HTMLElement {
787+
private _buildDomNode(): void {
788788
// Find input
789789
this._findInput = this._register(new ContextScopedFindInput(null, this._contextViewProvider, {
790790
width: FIND_INPUT_AREA_WIDTH,
@@ -908,10 +908,6 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
908908

909909
findPart.appendChild(this._closeBtn.domNode);
910910

911-
return findPart;
912-
}
913-
914-
private _buildReplacePart(): HTMLElement {
915911
// Replace input
916912
let replaceInput = document.createElement('div');
917913
replaceInput.className = 'replace-input';
@@ -977,16 +973,6 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
977973
replacePart.appendChild(this._replaceBtn.domNode);
978974
replacePart.appendChild(this._replaceAllBtn.domNode);
979975

980-
return replacePart;
981-
}
982-
983-
private _buildDomNode(): void {
984-
// Find part
985-
let findPart = this._buildFindPart();
986-
987-
// Replace part
988-
let replacePart = this._buildReplacePart();
989-
990976
// Toggle replace button
991977
this._toggleReplaceBtn = this._register(new SimpleButton({
992978
label: NLS_TOGGLE_REPLACE_MODE_BTN_LABEL,
@@ -1014,10 +1000,6 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
10141000
this._domNode.appendChild(findPart);
10151001
this._domNode.appendChild(replacePart);
10161002

1017-
this._buildSash();
1018-
}
1019-
1020-
private _buildSash() {
10211003
this._resizeSash = new Sash(this._domNode, this, { orientation: Orientation.VERTICAL });
10221004
this._resized = false;
10231005
let originalWidth = FIND_WIDGET_INITIAL_WIDTH;

src/vs/editor/contrib/folding/folding.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export class FoldingController extends Disposable implements IEditorContribution
7979
private cursorChangedScheduler: RunOnceScheduler | null;
8080

8181
private readonly localToDispose = this._register(new DisposableStore());
82+
private mouseDownInfo: { lineNumber: number, iconClicked: boolean } | null;
8283

8384
constructor(
8485
editor: ICodeEditor,
@@ -340,8 +341,6 @@ export class FoldingController extends Disposable implements IEditorContribution
340341

341342
}
342343

343-
private mouseDownInfo: { lineNumber: number, iconClicked: boolean } | null;
344-
345344
private onEditorMouseDown(e: IEditorMouseEvent): void {
346345
this.mouseDownInfo = null;
347346

src/vs/editor/contrib/hover/hover.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ export class ModesHoverController implements IEditorContribution {
3939

4040
get contentWidget(): ModesContentHoverWidget {
4141
if (!this._contentWidget) {
42-
this._createHoverWidget();
42+
this._createHoverWidgets();
4343
}
4444
return this._contentWidget!;
4545
}
4646

4747
get glyphWidget(): ModesGlyphHoverWidget {
4848
if (!this._glyphWidget) {
49-
this._createHoverWidget();
49+
this._createHoverWidgets();
5050
}
5151
return this._glyphWidget!;
5252
}
@@ -198,15 +198,15 @@ export class ModesHoverController implements IEditorContribution {
198198
}
199199

200200
private _hideWidgets(): void {
201-
if (!this._contentWidget || (this._isMouseDown && this._hoverClicked && this._contentWidget.isColorPickerVisible())) {
201+
if (!this._glyphWidget || !this._contentWidget || (this._isMouseDown && this._hoverClicked && this._contentWidget.isColorPickerVisible())) {
202202
return;
203203
}
204204

205205
this._glyphWidget!.hide();
206206
this._contentWidget.hide();
207207
}
208208

209-
private _createHoverWidget() {
209+
private _createHoverWidgets() {
210210
this._contentWidget = new ModesContentHoverWidget(this._editor, this._markerDecorationsService, this._themeService, this._keybindingService, this._modeService, this._openerService);
211211
this._glyphWidget = new ModesGlyphHoverWidget(this._editor, this._modeService, this._openerService);
212212
}

src/vs/editor/contrib/hover/hoverWidgets.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
7373
this._editor.addContentWidget(this);
7474
this._showAtPosition = null;
7575
this._showAtRange = null;
76+
this._stoleFocus = false;
7677
}
7778

7879
public getId(): string {

0 commit comments

Comments
 (0)