Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMat Booth2017-11-20 15:22:30 +0000
committerMat Booth2017-11-20 15:25:12 +0000
commitc0bb9064ab45f54c8e8c6453619a2c36edc2adca (patch)
tree90b76443c59a97bb2990186bc6c7801c0d9873d7
parentf007bfc2754f47a559d4193fb2b3b3c6b589b9c5 (diff)
downloadorg.eclipse.dltk.sh-c0bb9064ab45f54c8e8c6453619a2c36edc2adca.tar.gz
org.eclipse.dltk.sh-c0bb9064ab45f54c8e8c6453619a2c36edc2adca.tar.xz
org.eclipse.dltk.sh-c0bb9064ab45f54c8e8c6453619a2c36edc2adca.zip
Bug 520607 - Hover on command in script freezes UIR5_8_2
This change prevents hanging when loading a large man page in the hoverhelp by truncating very large pages and instead advising users to use the show man page command to view the man page in the dedicated man page view Change-Id: Ia668cdd01aa235e74ed5e8558bd316c7590c386d Signed-off-by: Mat Booth <mat.booth@redhat.com>
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/plugin.xml12
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java20
2 files changed, 27 insertions, 5 deletions
diff --git a/plugins/org.eclipse.dltk.sh.ui/plugin.xml b/plugins/org.eclipse.dltk.sh.ui/plugin.xml
index b0f844a..26ff717 100644
--- a/plugins/org.eclipse.dltk.sh.ui/plugin.xml
+++ b/plugins/org.eclipse.dltk.sh.ui/plugin.xml
@@ -200,9 +200,9 @@
</command>
<command
defaultHandler="org.eclipse.dltk.sh.internal.ui.commands.ShowManHandler"
- description="Show man page view"
+ description="Show command in the man page view"
id="org.eclipse.dltk.sh.ui.showman"
- name="Show man page">
+ name="Show Man Page">
</command>
<command
defaultHandler="org.eclipse.dltk.sh.internal.ui.commands.AddNature"
@@ -286,6 +286,14 @@
</visibleWhen>
</command>
</menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.dltk.sh.ui.editor.EditorContext?after=additions">
+ <command
+ commandId="org.eclipse.dltk.sh.ui.showman"
+ style="push">
+ </command>
+ </menuContribution>
</extension>
<extension
point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java
index 239300e..8787cdb 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java
@@ -30,11 +30,25 @@ public class ShellDocumentationProvider implements IScriptDocumentationProvider
if (!helpInfo.isEmpty()) {
return new StringReader("<pre>" + helpInfo + "</pre>");
}
- String info = new ManPage(content).getStrippedHtmlPage().toString();
- if (info.equals("<pre></pre>")) {
+ StringBuilder manInfo = new ManPage(content).getStrippedPage();
+ if (manInfo.length() == 0) {
return null;
}
- return new StringReader(info);
+ // Any more than ~10kb and the hover help starts to take a really long time to
+ // render, so truncate it in that case and advise to use the man page view
+ final int maxLen = 1024 * 10;
+ StringBuilder sb = new StringBuilder("<pre>");
+ if (manInfo.length() > maxLen) {
+ sb.append(manInfo.substring(0, maxLen));
+ } else {
+ sb.append(manInfo);
+ }
+ sb.append("</pre>");
+ if (manInfo.length() > maxLen) {
+ sb.append(
+ "<p>This man page is truncated, use <b>Show Man Page</b> (Alt+M) to see the whole page for the selected word.</p>");
+ }
+ return new StringReader(sb.toString());
}
private static String getHelp(String command) {

Back to the top