Skip to content

Terminal: fix moving a terminal tab to another terminals view - #2979

Open
insjang wants to merge 4 commits into
eclipse-platform:masterfrom
insjang:terminal-dnd-recreate
Open

insjang wants to merge 4 commits into
eclipse-platform:masterfrom
insjang:terminal-dnd-recreate

Conversation

@insjang

@insjang insjang commented Sep 30, 2026

Copy link
Copy Markdown

Dragging a terminal tab to another terminals view (the view's "New Terminal View" button, then drag a tab across) currently fails:

  • The tab stays in the source view, and both terminals go blank.
  • The error log shows SWTException: Widget is disposed, thrown from StyleMap.updateFont via VT100TerminalControl.setupTerminal.

Cause

setupTerminal(Composite) recreates the controls in the new parent. The TextLineRenderer of the new canvas measures the font on fCtlText, but at that point fCtlText is still the canvas that was just disposed.

A second problem shows once that is fixed: the preferences (colors, font, buffer size) were only applied to freshly created terminals, so a moved terminal fell back to the default colors and font.

Fix

  • The renderer measures on the display while the new canvas does not exist yet, as it already does for the first canvas.
  • setupTerminal applies the preferences to recreated controls too. The property change listener is still added only once.

Test

TerminalControlRecreateUITest recreates a terminal in a new parent, as the drag and drop does:

  • Without the first change it fails with "Widget is disposed".
  • Without the second change the background color preference is lost.

The existing terminal tests pass.

Dragging a terminal tab to another terminals view recreates the terminal
controls in the new view. This failed in two ways:

- The text line renderer of the new canvas measured the font on
  fCtlText, which at that point still is the canvas that was just
  disposed. The move stopped with "Widget is disposed", leaving the tab
  behind and both terminals blank.
- The preferences were only applied to freshly created terminals, so a
  moved terminal fell back to the default colors and font.

The renderer now measures on the display while the new canvas does not
exist yet, and the preferences are applied to recreated controls too.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Test teardown leaks terminal resources, and both modified plug-ins require bundle version increments.

Review effort: Balanced
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

Fixes terminal tab migration between terminal views by safely recreating controls and preserving preferences.

Changes:

  • Avoids measuring fonts against a disposed canvas.
  • Reapplies terminal preferences after control recreation.
  • Adds UI regression coverage for recreation and preference retention.
File Description
AutomatedTestSuite.java Registers the new UI test.
TerminalControlRecreateUITest.java Tests control recreation and preference retention.
VT100TerminalControl.java Fixes recreation and reapplies preferences.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@eclipse-platform-bot

Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

terminal/bundles/org.eclipse.terminal.control/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From cafa0e6a979729754a22c0bfe208fbcf85e855b8 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Wed, 30 Sep 2026 08:20:56 +0000
Subject: [PATCH] Version bump(s) for 4.42 stream


diff --git a/terminal/bundles/org.eclipse.terminal.control/META-INF/MANIFEST.MF b/terminal/bundles/org.eclipse.terminal.control/META-INF/MANIFEST.MF
index ff5a3fb72b..0c618bbd15 100644
--- a/terminal/bundles/org.eclipse.terminal.control/META-INF/MANIFEST.MF
+++ b/terminal/bundles/org.eclipse.terminal.control/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.terminal.control; singleton:=true
-Bundle-Version: 1.1.200.qualifier
+Bundle-Version: 1.1.300.qualifier
 Bundle-Activator: org.eclipse.terminal.internal.control.impl.TerminalPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
-- 
2.55.0

Further information are available in Common Build Issues - Missing version increments.

As the terminals view does when a terminal tab is closed, so the terminal
does not stay registered in the font registry after the test.
TextCanvas.getTerminalBackgroundColor() is protected: in OSGi the test
bundle is another runtime package, so the test failed with an
IllegalAccessError. The renderer's getDefaultBackgroundColor() is public.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants