Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/diff/base-unified-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export abstract class BaseUnifiedDiffManager {
return;
}
this._isDisposed = true;
this._deactivate();
this.deactivate();
}

/**
Expand Down Expand Up @@ -112,7 +112,7 @@ export abstract class BaseUnifiedDiffManager {
/**
* Deactivate the diff view
*/
protected _deactivate(): void {
protected deactivate(): void {
this.removeToolbarButtons();
this._cleanupEditor();
this.showCellToolbar();
Expand All @@ -137,7 +137,7 @@ export abstract class BaseUnifiedDiffManager {
*/
protected acceptAll(): void {
// simply accept the current state
this._deactivate();
this.deactivate();
}

/**
Expand All @@ -146,7 +146,7 @@ export abstract class BaseUnifiedDiffManager {
protected rejectAll(): void {
const sharedModel = this.getSharedModel();
sharedModel.setSource(this._originalSource);
this._deactivate();
this.deactivate();
}

/**
Expand All @@ -166,7 +166,7 @@ export abstract class BaseUnifiedDiffManager {
newSource: this._newSource,
isInitialized: this._isInitialized,
sharedModel: this.getSharedModel(),
onChunkChange: () => this._deactivate()
onChunkChange: () => this.deactivate()
});

this._isInitialized = true;
Expand Down
18 changes: 11 additions & 7 deletions src/diff/unified-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class UnifiedCellDiffManager extends BaseUnifiedDiffManager {
}

private static _activeDiffCount = 0;
private _toolbarObserver?: MutationObserver;

/**
* Get the shared model for source manipulation
Expand All @@ -61,29 +62,32 @@ export class UnifiedCellDiffManager extends BaseUnifiedDiffManager {
subtree: true
});

(this as any)._toolbarObserver = observer;
this._toolbarObserver = observer;
}

/**
* Deactivate the diff view with cell toolbar.
*/
protected _deactivate(): void {
super['_deactivate']();
protected deactivate(): void {
super.deactivate();
UnifiedCellDiffManager._activeDiffCount = Math.max(
0,
UnifiedCellDiffManager._activeDiffCount - 1
);

const observer = (this as any)._toolbarObserver as MutationObserver;
if (observer) {
observer.disconnect();
if (this._toolbarObserver) {
this._toolbarObserver.disconnect();
this._toolbarObserver = undefined;
}
}

/**
* Hide the cell's toolbar while the diff is active
*/
protected hideCellToolbar(): void {
const toolbar = this._cell.node.querySelector('jp-toolbar') as HTMLElement;
const toolbar = this._cell.node.querySelector(
'jp-toolbar'
) as HTMLElement | null;
if (toolbar) {
toolbar.style.display = 'none';
}
Expand Down
Loading