Skip to content

Commit

Permalink
terminal: fix firefox monkeypatching
Browse files Browse the repository at this point in the history
Signed-off-by: vince-fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Jul 20, 2023
1 parent abc4578 commit f572553
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/terminal/src/browser/terminal-widget-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,23 +642,20 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
// monkey patching intersection observer handling for secondary window support
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const renderService: any = (this.term as any)._core._renderService;
const originalFunc: (entry: IntersectionObserverEntry) => void = renderService._onIntersectionChange.bind(renderService);
const originalFunc: (entry: IntersectionObserverEntry) => void = renderService._handleIntersectionChange.bind(renderService);
const replacement = function (entry: IntersectionObserverEntry): void {
if (entry.target.ownerDocument !== document) {
// in Firefox, the intersection observer always reports the widget as non-intersecting if the dom element
// is in a different document from when the IntersectionObserver started observing. Since we know
// that the widget is always "visible" when in a secondary window, so we mark the entry as "intersecting"
const patchedEvent: IntersectionObserverEntry = {
...entry,
isIntersecting: true,
};
originalFunc(patchedEvent);
// that the widget is always "visible" when in a secondary window, so we refresh the rows ourselves
renderService._pausedResizeTask.flush();
renderService.refreshRows(0, renderService._rowCount - 1);
} else {
originalFunc(entry);
}
};

renderService._onIntersectionChange = replacement;
renderService._handleIntersectionChange = replacement;
}

if (this.initialData) {
Expand Down

0 comments on commit f572553

Please sign in to comment.