Skip to content

Commit 351793a

Browse files
committed
fix: reduce LSPTextHover resize flicker
1 parent 8747384 commit 351793a

4 files changed

Lines changed: 20 additions & 13 deletions

File tree

org.eclipse.lsp4e/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Language Server Protocol client for Eclipse IDE (Incubation)
44
Bundle-SymbolicName: org.eclipse.lsp4e;singleton:=true
5-
Bundle-Version: 0.19.3.qualifier
5+
Bundle-Version: 0.19.4.qualifier
66
Bundle-RequiredExecutionEnvironment: JavaSE-21
77
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0",
88
org.eclipse.equinox.common;bundle-version="3.8.0",

org.eclipse.lsp4e/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<artifactId>org.eclipse.lsp4e</artifactId>
1212
<packaging>eclipse-plugin</packaging>
13-
<version>0.19.3-SNAPSHOT</version>
13+
<version>0.19.4-SNAPSHOT</version>
1414

1515
<build>
1616
<plugins>

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/hover/FocusableBrowserInformationControl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private void updateBrowserSize(final Browser browser) {
103103
setSize(hint.x, hint.y);
104104

105105
if (!"complete".equals(safeEvaluate(browser, "return document.readyState"))) { //$NON-NLS-1$ //$NON-NLS-2$
106-
UI.getDisplay().timerExec(200, () -> updateBrowserSize(browser));
106+
UI.getDisplay().timerExec(50, () -> updateBrowserSize(browser));
107107
return;
108108
}
109109

@@ -191,6 +191,7 @@ public void setInput(@Nullable Object input) {
191191
}));
192192
return;
193193
}
194+
this.currentAsyncToken = null;
194195
if (input instanceof String html) {
195196
input = styleHtml(html);
196197
}

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/hover/LSPTextHover.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
public class LSPTextHover implements ITextHover, ITextHoverExtension, ITextHoverExtension2 {
6868

6969
private static final int GET_HOVER_REGION_TIMEOUT_MS = 100;
70+
private static final int GET_HOVER_INFO_TIMEOUT_MS = 100;
7071

7172
private @Nullable IRegion lastRegion;
7273
private @Nullable ITextViewer lastViewer;
@@ -75,24 +76,29 @@ public class LSPTextHover implements ITextHover, ITextHoverExtension, ITextHover
7576

7677
@Override
7778
public @Nullable String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
78-
// Non-blocking: only return immediately available content.
7979
final var hoverInfoRequest_ = this.hoverInfoFuture = getHoverInfoFuture(textViewer, hoverRegion);
80-
if (hoverInfoRequest_.isDone()) {
81-
try {
82-
return hoverInfoRequest_.getNow(null);
83-
} catch (final Exception ex) {
84-
if (CancellationUtil.isRequestCancelledException(ex)) {
85-
// Hover was cancelled; ignore as this is an expected fast-mouse-move scenario.
86-
return null;
87-
}
88-
LanguageServerPlugin.logError(ex);
80+
try {
81+
return hoverInfoRequest_.get(GET_HOVER_INFO_TIMEOUT_MS, TimeUnit.MILLISECONDS);
82+
} catch (InterruptedException ex) {
83+
LanguageServerPlugin.logError(ex);
84+
Thread.currentThread().interrupt();
85+
return null;
86+
} catch (ExecutionException | TimeoutException ex) {
87+
if (CancellationUtil.isRequestCancelledException(ex)) {
88+
// Hover was cancelled; ignore as this is an expected fast-mouse-move scenario.
89+
return null;
8990
}
91+
LanguageServerPlugin.logError(ex);
9092
}
9193
return null;
9294
}
9395

9496
@Override
9597
public @Nullable Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
98+
final var hoverInfo = getHoverInfo(textViewer, hoverRegion);
99+
if (hoverInfo != null)
100+
return hoverInfo;
101+
96102
final var hoverInfoRequest_ = this.hoverInfoFuture = getHoverInfoFuture(textViewer, hoverRegion);
97103
final String placeholder = "<html><body>Loading…</body></html>"; //$NON-NLS-1$
98104
return new AsyncHtmlHoverInput(hoverInfoRequest_, placeholder);

0 commit comments

Comments
 (0)