xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.04k stars 1.6k forks source link

The terminal instance cannot be rendered correctly after calling `.open()` for the second time. #4978

Open 1zilc opened 4 months ago

1zilc commented 4 months ago

I am new to using xtermjs. I am not sure whether the terminal instance can call the open() method multiple times. According to the official documentation and https://github.com/xtermjs/xterm.js/issues/1323, I tried it. When I removed the dom and mounted again, and used terminal.open(), xterm did not render after the second open.

Details

Steps to reproduce

Reproduce

  1. Click the toggle button, xterm renders correctly.
  2. Click the toggle button, remove dom
  3. Click the toggle button, mount dom, xterm did not render after the second open

I'm sorry if there's something wrong with my usage

jerch commented 4 months ago

I am not very deep into the browser side of the code, @Tyriar has more insights here. Still I think it is not possible to move an already DOM-attached terminal to another DOM node by calling open again.

@Tyriar Do we need an attach/detach cycling for the DOM hooking? It never came to me before, that someone would want to move an existing terminal to another DOM node, so this might be just a wild idea of limited use. Loosely linked or more generalized to this would be support of a copy ctor like const term2 = new Terminal(term1), where the new terminal could start over in DOM-detached mode, but has inherited all VT-related settings/data. This has some intersections with the serialize addon, so might not be worth either the trouble.