-
Notifications
You must be signed in to change notification settings - Fork 177
Terminal: fix moving a terminal tab to another terminals view #2979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
insjang
wants to merge
4
commits into
eclipse-platform:master
Choose a base branch
from
insjang:terminal-dnd-recreate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
acce1d7
Terminal: fix moving a terminal tab to another terminals view
insjang 366fd25
Version bump(s) for 4.42 stream
eclipse-platform-bot f0b6812
Terminal: dispose the terminal after the recreate test
insjang d17d8a4
Terminal: read the background color through the renderer in the test
insjang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...inal.test/src/org/eclipse/terminal/internal/textcanvas/TerminalControlRecreateUITest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 Eclipse contributors and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| *******************************************************************************/ | ||
| package org.eclipse.terminal.internal.textcanvas; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import org.eclipse.jface.preference.PreferenceStore; | ||
| import org.eclipse.swt.graphics.RGB; | ||
| import org.eclipse.swt.layout.FillLayout; | ||
| import org.eclipse.swt.widgets.Composite; | ||
| import org.eclipse.swt.widgets.Display; | ||
| import org.eclipse.swt.widgets.Shell; | ||
| import org.eclipse.terminal.connector.ITerminalConnector; | ||
| import org.eclipse.terminal.connector.TerminalState; | ||
| import org.eclipse.terminal.control.ITerminalListener; | ||
| import org.eclipse.terminal.control.TerminalTitleRequestor; | ||
| import org.eclipse.terminal.internal.emulator.VT100TerminalControl; | ||
| import org.eclipse.terminal.internal.preferences.ITerminalConstants; | ||
| import org.eclipse.terminal.model.TerminalColor; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Tests recreating the terminal controls in a new parent, as moving a terminal tab to another | ||
| * terminals view does. | ||
| */ | ||
| public class TerminalControlRecreateUITest { | ||
|
|
||
| private static final RGB BACKGROUND = new RGB(1, 2, 3); | ||
|
|
||
| private Display display; | ||
| private Shell shell; | ||
| private VT100TerminalControl terminal; | ||
|
|
||
| @BeforeEach | ||
| public void createTerminal() { | ||
| display = Display.getCurrent() != null ? null : new Display(); | ||
| shell = new Shell(); | ||
| shell.setLayout(new FillLayout()); | ||
| PreferenceStore preferences = new PreferenceStore(); | ||
| preferences.setValue(ITerminalConstants.getPrefForTerminalColor(TerminalColor.BACKGROUND), | ||
| "1,2,3"); //$NON-NLS-1$ | ||
| ITerminalListener listener = new ITerminalListener() { | ||
| @Override | ||
| public void setState(TerminalState state) { | ||
| } | ||
|
|
||
| @Override | ||
| public void setTerminalSelectionChanged() { | ||
| } | ||
|
|
||
| @Override | ||
| public void setTerminalTitle(String title, TerminalTitleRequestor requestor) { | ||
| } | ||
| }; | ||
| terminal = new VT100TerminalControl(listener, new Composite(shell, 0), new ITerminalConnector[0], preferences); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void dispose() { | ||
| // as the terminals view does when a terminal tab is closed | ||
| terminal.disposeTerminal(); | ||
| shell.dispose(); | ||
| if (display != null) { | ||
| display.dispose(); | ||
| } | ||
| } | ||
|
|
||
| private void recreateInNewParent() { | ||
| terminal.setupTerminal(new Composite(shell, 0)); | ||
| } | ||
|
|
||
| @Test | ||
| public void recreatingDoesNotUseTheDisposedCanvas() { | ||
| assertDoesNotThrow(this::recreateInNewParent); | ||
| } | ||
|
|
||
| @Test | ||
| public void recreatedCanvasKeepsThePreferences() { | ||
| assertEquals(BACKGROUND, ((TextCanvas) terminal.getControl()).getCellRenderer().getDefaultBackgroundColor().getRGB()); | ||
| recreateInNewParent(); | ||
| assertEquals(BACKGROUND, ((TextCanvas) terminal.getControl()).getCellRenderer().getDefaultBackgroundColor().getRGB()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.