Try to handle terminal fit a bit better; closes #3121
I'm not sure how to fix this actually, but based on the light reading I did theoretically this should at least prevent it from trying to fit something that doesn't even exist?
This commit is contained in:
parent
bc87a9cf7d
commit
68bc81f2f1
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { ITerminalOptions, Terminal } from 'xterm';
|
import { ITerminalOptions, Terminal } from 'xterm';
|
||||||
import { FitAddon } from 'xterm-addon-fit';
|
import { FitAddon } from 'xterm-addon-fit';
|
||||||
import { SearchAddon } from 'xterm-addon-search';
|
import { SearchAddon } from 'xterm-addon-search';
|
||||||
|
@ -135,11 +135,12 @@ export default () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (connected && ref.current && !terminal.element) {
|
if (connected && ref.current && !terminal.element) {
|
||||||
terminal.open(ref.current);
|
|
||||||
terminal.loadAddon(fitAddon);
|
terminal.loadAddon(fitAddon);
|
||||||
terminal.loadAddon(searchAddon);
|
terminal.loadAddon(searchAddon);
|
||||||
terminal.loadAddon(searchBar);
|
terminal.loadAddon(searchBar);
|
||||||
terminal.loadAddon(webLinksAddon);
|
terminal.loadAddon(webLinksAddon);
|
||||||
|
|
||||||
|
terminal.open(ref.current);
|
||||||
fitAddon.fit();
|
fitAddon.fit();
|
||||||
|
|
||||||
// Add support for capturing keys
|
// Add support for capturing keys
|
||||||
|
@ -159,11 +160,11 @@ export default () => {
|
||||||
}
|
}
|
||||||
}, [ terminal, connected ]);
|
}, [ terminal, connected ]);
|
||||||
|
|
||||||
const fit = debounce(() => {
|
useEventListener('resize', debounce(() => {
|
||||||
fitAddon.fit();
|
if (terminal.element) {
|
||||||
}, 100);
|
fitAddon.fit();
|
||||||
|
}
|
||||||
useEventListener('resize', () => fit());
|
}, 100));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const listeners: Record<string, (s: string) => void> = {
|
const listeners: Record<string, (s: string) => void> = {
|
||||||
|
|
Loading…
Reference in New Issue