From a7417cf75d68689ea0bc275f0062fc90d7a5afd1 Mon Sep 17 00:00:00 2001 From: Arnaud Fabre Date: Sat, 29 Jun 2013 23:41:01 +0200 Subject: [PATCH] PrettyFormatter: Fix expand tab when syntax coloring is on. prettify lost support for expanding tabs in r143 [1]. As a consequence, tab width preference is no longer honored. Gerrit now handles expanding tabs by itself in all cases, even if syntax coloring is active. [1] http://code.google.com/p/google-code-prettify/source/detail?r=143 Bug: issue 1872 Change-Id: I283a3620b1d130d3f66e56d3f202a5122d7a73b8 --- .../google/gerrit/prettify/client/ClientSideFormatter.java | 5 ++--- .../com/google/gerrit/prettify/common/PrettyFormatter.java | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/client/ClientSideFormatter.java b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/client/ClientSideFormatter.java index 1436bba860..8d5ddb9000 100644 --- a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/client/ClientSideFormatter.java +++ b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/client/ClientSideFormatter.java @@ -62,13 +62,12 @@ public class ClientSideFormatter extends PrettyFormatter { @Override protected String prettify(String html, String type) { - return go(prettify.getContext(), html, type, diffPrefs.getTabSize()); + return go(prettify.getContext(), html, type); } private static native String go(JavaScriptObject ctx, String srcText, - String srcType, int tabSize) + String srcType) /*-{ - ctx.PR_TAB_WIDTH = tabSize; return ctx.prettyPrintOne(srcText, srcType); }-*/; } diff --git a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java index d07a34da79..5786e9587a 100644 --- a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java +++ b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java @@ -128,6 +128,7 @@ public abstract class PrettyFormatter implements SparseHtmlFile { String html = toHTML(src); + html = expandTabs(html); if (diffPrefs.isSyntaxHighlighting() && getFileType() != null && src.isWholeFile()) { // The prettify parsers don't like ' as an entity for the @@ -148,8 +149,6 @@ public abstract class PrettyFormatter implements SparseHtmlFile { html = html.replaceAll("(\r)?\n", " $1\n"); html = prettify(html, getFileType()); html = html.replaceAll(" (\r)?\n", "$1\n"); - } else { - html = expandTabs(html); } int pos = 0;