From 40737c8f3210f7c36c9407ac53d5c7aeeff7fa71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 23 Aug 2022 19:29:36 +0300 Subject: [PATCH] Make sure LSP notification message is wrapped Caused by long standing SWT issue ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=194758 ) but easily workaroundable as done in this patch. Some minor SonarLint warnings are also fixed. Fixes https://github.com/eclipse/lsp4e/issues/220 . --- .../src/org/eclipse/lsp4e/ServerMessageHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/ServerMessageHandler.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/ServerMessageHandler.java index e05a5854e..ab3856e85 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/ServerMessageHandler.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/ServerMessageHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2021 Rogue Wave Software Inc. and others. + * Copyright (c) 2016, 2022 Rogue Wave Software Inc. and others. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -22,6 +22,7 @@ import org.eclipse.lsp4j.ShowMessageRequestParams; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; @@ -53,8 +54,9 @@ public String getPopupShellTitle() { @Override protected void createContentArea(Composite parent) { - Label label = new Label(parent, SWT.WRAP); - label.setText(messageParams.getMessage()); + Label messageLabel = new Label(parent, SWT.WRAP); + messageLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + messageLabel.setText(messageParams.getMessage()); } @Override @@ -102,7 +104,7 @@ public static void showMessage(String title, MessageParams params) { } public static CompletableFuture showMessageRequest(LanguageServerWrapper wrapper, ShowMessageRequestParams params) { - String options[] = params.getActions().stream().map(MessageActionItem::getTitle).toArray(String[]::new); + String[] options = params.getActions().stream().map(MessageActionItem::getTitle).toArray(String[]::new); CompletableFuture future = new CompletableFuture<>(); Display.getDefault().asyncExec(() -> {