Add font zoom functionality to console view - #2579
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Ctrl +/- (including numpad +/-) zoom support to the Eclipse Console view to align behavior with text editors (Issue #2578).
Changes:
- Installs a key listener on the console’s
StyledTextto detect Ctrl+Plus / Ctrl+Minus. - Implements font resizing logic with min/max bounds and a step size, creating a derived SWT
Font. - Disposes the created font on view disposal.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
74720eb to
21d419f
Compare
|
Have you thought about persisting the current zoom over the current session? That will be likely next immediate customer request after using this feature for the first time & IDE restart. Assuming the code moved to the page (from the console), we would always know "where we are" and should be able to persist the zoom in the preference store by using the |
21d419f to
c051ad1
Compare
|
@trancexpress Please check this PR. |
|
With: The Console view can be zoomed when I'm in the Java editor and I press: The change here makes me press The Java editor zoom in / zoom out resets whatever the zoom level was in the console, which is probably OK. |
There was a problem hiding this comment.
Pull request overview
Adds Ctrl +/- key handling to the Console view’s text widget to support zooming the console font size, addressing the usability gap described in #2578.
Changes:
- Add a key listener on the console
StyledTextto zoom font size on Ctrl + / Ctrl - (including numpad +/-). - Implement per-console-type font persistence via the console plug-in preference store and restore it on page creation.
- Minor whitespace adjustment in
ConsoleView.dispose().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java | Minor formatting-only change in dispose(). |
| debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java | Adds zoom key listener, font resizing logic, and preference-based font load/save for console pages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cb6dbf0 to
0c77159
Compare
9dd0a16 to
e1d88b4
Compare
|
@iloveeclipse Please check this PR. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e1d88b4 to
8c76e12
Compare
iloveeclipse
left a comment
There was a problem hiding this comment.
Note: before pushing fixes, please rebase on master first.
| } | ||
| FontData[] newFontData = fontData.clone(); | ||
| for (FontData fd : newFontData) { | ||
| if (fd != null) |
There was a problem hiding this comment.
Please always use blocks for if/for/while statements, independently how many lines are inside.
iloveeclipse
left a comment
There was a problem hiding this comment.
Note: before pushing fixes, please rebase on master first.
iloveeclipse
left a comment
There was a problem hiding this comment.
Note: before pushing fixes, please rebase on master first.
8c76e12 to
5cc0461
Compare
5cc0461 to
b114c03
Compare
|
@raghucssit : I don't see changes in the patch itself after last rebase you did? |
b114c03 to
2f6f049
Compare
|
I have fixed all the review comments and issues present at last review..
|
|
Regarding bug that activates editor content on selection of Stacktrace Console has the below fix. I will create a separate issue at jdt debug repo and contribute below patch. |
|
Stacktrace of the Exception if we don't use Display UI execution. Async is used to avoid any possible deadlocks. |
iloveeclipse
left a comment
There was a problem hiding this comment.
Quick review: have not tested yet, but I see some pieces that need to be fixed.
2f6f049 to
dda32dc
Compare
|
816b946 to
1250be0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java:362
applyHeight(...)addsFONT_ENFORCERon every zoom application. BecauseAbstractConsole#addPropertyChangeListenerdoes not deduplicate listeners, repeated zoom steps will register the same listener multiple times, causing redundantonFontChanged(...)invocations and makingremovePropertyChangeListeneron console removal insufficient.
// make sure this console's font is (still) being watched, in case it was
// registered before the zoom handler class got loaded, or the listener
// was otherwise not yet attached
textConsole.addPropertyChangeListener(FONT_ENFORCER);
1250be0 to
86f9070
Compare
86f9070 to
c48c00d
Compare
| * expose its preference key as public API. | ||
| */ | ||
| private static String getPersistedZoomState() throws ReflectiveOperationException { | ||
| Field prefKeyField = ConsoleZoomInHandler.class.getDeclaredField("PREF_ZOOM_FONT_HEIGHTS"); //$NON-NLS-1$ |
There was a problem hiding this comment.
Please if you already created helper function getStaticIntField, use it consistently.
But I would ask here instead: remove all the reflection and make all the required constants in ConsoleZoomInHandler public.
| public void testRemovingConsoleDisposesZoomFont(TestInfo testInfo) throws Exception { | ||
| String type = uniqueConsoleType("disposeOnRemove"); //$NON-NLS-1$ | ||
|
|
||
| IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
There was a problem hiding this comment.
The code which opens console view below repeats in every test. Please extract method for that.
| handlerService.executeCommand("org.eclipse.ui.console.command.fontZoomIn", null); //$NON-NLS-1$ | ||
| TestUtil.processUIEvents(); | ||
|
|
||
| assertEquals(naturalHeight + 1, getFontHeight(console), |
There was a problem hiding this comment.
The second command (zoom out) is not verified, but should
There was a problem hiding this comment.
And while writing this above, I've asked myself why do we need two handler classes at all, where second one doesn't do anything but just redirects to the first one with a different step?
Instead, we should have one ConsoleZoomHandler handler and parametrize that. Please check patch below which provides minimal changes (without rename to ConsoleZoomHandler for simplicity). Please apply it and rename the one handler to ConsoleZoomHandler & update Console tests to the new name.
diff --git a/debug/org.eclipse.ui.console/plugin.xml b/debug/org.eclipse.ui.console/plugin.xml
index 48cd9f4..a6a8aef 100644
--- a/debug/org.eclipse.ui.console/plugin.xml
+++ b/debug/org.eclipse.ui.console/plugin.xml
@@ -214,3 +214,3 @@
<handler
- class="org.eclipse.ui.internal.console.ConsoleZoomOutHandler"
+ class="org.eclipse.ui.internal.console.ConsoleZoomInHandler:-1"
commandId="org.eclipse.ui.console.command.fontZoomOut">
diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java
index b7b2026..c3361fd 100644
--- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java
+++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java
@@ -22,2 +22,5 @@
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.Status;
@@ -41,4 +44,4 @@
/**
- * Command handler to increase the font size of the console currently shown in
- * the active console view.
+ * Command handler to increase or decrease the font size of the console
+ * currently shown in the active console view.
* <p>
@@ -50,4 +53,11 @@
* </p>
+ * <p>
+ * This single class backs both the zoom-in and zoom-out commands: the
+ * direction is supplied as executable extension data in {@code plugin.xml},
+ * e.g. {@code class="...ConsoleZoomInHandler:-1"} for zooming out. Each
+ * {@code <handler>} registration gets its own instance, so there is no shared
+ * mutable state between the two directions.
+ * </p>
*/
-public class ConsoleZoomInHandler extends AbstractHandler {
+public class ConsoleZoomInHandler extends AbstractHandler implements IExecutableExtension {
@@ -70,2 +80,10 @@
/**
+ * The zoom direction/step size for this particular handler instance, in
+ * points; positive to zoom in, negative to zoom out. Set from the
+ * executable extension data configured in {@code plugin.xml} (defaults to
+ * {@link #STEP}, i.e. zoom in, if none is provided).
+ */
+ private int step = STEP;
+
+ /**
* Key used, in the per-type persisted zoom string, for consoles that report a
@@ -269,5 +287,17 @@
@Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+ throws CoreException {
+ if (data instanceof String stepData) {
+ try {
+ step = Integer.parseInt(stepData.trim());
+ } catch (NumberFormatException e) {
+ // keep default (zoom in) if the configured data is not a valid integer
+ }
+ }
+ }
+
+ @Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePart(event);
- applyZoom(part, STEP);
+ applyZoom(part, step);
return Status.OK_STATUS;
diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomOutHandler.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomOutHandler.java
deleted file mode 100644
index aef9296..0000000
--- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomOutHandler.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2026 Advantest Europe GmbH 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
- *
- * Contributors:
- * Raghunandana Murthappa
- *******************************************************************************/
-package org.eclipse.ui.internal.console;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Command handler to decrease the font size of the console currently shown in
- * the active console view.
- *
- * @see ConsoleZoomInHandler
- */
-public class ConsoleZoomOutHandler extends AbstractHandler {
- private static final int STEP = 1;
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- ConsoleZoomInHandler.applyZoom(part, -STEP);
- return Status.OK_STATUS;
- }
-}
| IViewPart consoleViewPart = activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW); | ||
| IConsoleView consoleView = (IConsoleView) consoleViewPart; | ||
|
|
||
| MessageConsole console = new MessageConsole("Zoom Dispose Console", type, null, //$NON-NLS-1$ |
There was a problem hiding this comment.
The code which creates and adds console to the manager below repeats in every test, just with different console names. Please extract method for that.
c48c00d to
2264409
Compare
-Add key listener on text widget of console view which listens ctrl plus and control minus(including numpad +/-) -Zoom in/out of the console view text in steps based on the keys pressed. see eclipse-platform#2578
2264409 to
a5f5e6a
Compare
-Add key listener on text widget of console view which listens ctrl plus and control minus(including numpad +/-)
-Zoom in/out of the console view text in steps based on the keys pressed.
see #2578