Adds a new pref config called lineWrapping to Edit and Diff
What this config does is it either enables or disables lineWrapping, disabling line wrapping can cause changes that have long lines to simply be cut off. With it enabled it will line wrap the text making it easer to read instead of it being cutoff. Gerrit 2.8.1 did lineWrapping so bringing this back. But it is set to the default false so it is not enabled by default in Edit or Diff sections. We should probaly set it as true in gerrit 2.13. This also will partially fix bug https://phabricator.wikimedia.org/T144565 which is filled downstream. Reason why this is partially fixed is because the pref is not set to true by default and logged out users will still see no line wrapping. Bug: Issue 4292 Bug: Issue 2410 Change-Id: I8600778f1068c217e335755a3138e8cb64bc8b3e
This commit is contained in:
@@ -1358,6 +1358,7 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
|
||||
"show_whitespace_errors": true,
|
||||
"hide_line_numbers": true,
|
||||
"match_brackets": true,
|
||||
"line_wrapping": false,
|
||||
"auto_close_brackets": true
|
||||
}
|
||||
----
|
||||
@@ -1390,6 +1391,7 @@ link:#edit-preferences-info[EditPreferencesInfo] entity.
|
||||
"syntax_highlighting": true,
|
||||
"hide_line_numbers": true,
|
||||
"match_brackets": true,
|
||||
"line_wrapping": false,
|
||||
"auto_close_brackets": true
|
||||
}
|
||||
----
|
||||
@@ -1714,6 +1716,8 @@ Whether empty panes should be hidden. The left pane is empty when a
|
||||
file was added; the right pane is empty when a file was deleted.
|
||||
|`match_brackets` |not set if `false`|
|
||||
Whether matching brackets should be highlighted.
|
||||
|`line_wrapping` |not set if `false`|
|
||||
Whether to enable line wrapping or not.
|
||||
|===========================================
|
||||
|
||||
[[diff-preferences-input]]
|
||||
@@ -1767,6 +1771,8 @@ scrolling down more than half of a page.
|
||||
True if the line numbers should be hidden.
|
||||
|`tab_size` |optional|
|
||||
Number of spaces that should be used to display one tab.
|
||||
|`line_wrapping` |optional|
|
||||
Whether to enable line wrapping or not.
|
||||
|===========================================
|
||||
|
||||
[[edit-preferences-info]]
|
||||
@@ -1803,6 +1809,8 @@ Whether syntax highlighting should be enabled.
|
||||
Whether line numbers should be hidden.
|
||||
|`match_brackets` |not set if `false`|
|
||||
Whether matching brackets should be highlighted.
|
||||
|`line_wrapping` |not set if `false`|
|
||||
Whether to enable line wrapping or not.
|
||||
|`auto_close_brackets` |not set if `false`|
|
||||
Whether brackets and quotes should be auto-closed during typing.
|
||||
|===========================================
|
||||
|
||||
@@ -1087,6 +1087,15 @@ file.
|
||||
+
|
||||
Large files that exceed 4000 lines will not be fully rendered.
|
||||
|
||||
- [[line-wrapping]]`Line Wrapping`:
|
||||
+
|
||||
Controls weather to enable line wrapping or not.
|
||||
+
|
||||
If `false` is selected then line wrapping is disabled.
|
||||
This is the default option.
|
||||
+
|
||||
If `true` is selected then line wrapping is enabled.
|
||||
|
||||
[[keyboard-shortcuts]]
|
||||
== Keyboard Shortcuts
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ public class DiffPreferencesIT extends AbstractDaemonTest {
|
||||
assertThat(o.renderEntireFile).isNull();
|
||||
assertThat(o.hideEmptyPane).isNull();
|
||||
assertThat(o.matchBrackets).isNull();
|
||||
assertThat(o.lineWrapping).isNull();
|
||||
assertThat(o.ignoreWhitespace).isEqualTo(d.ignoreWhitespace);
|
||||
assertThat(o.theme).isEqualTo(d.theme);
|
||||
}
|
||||
@@ -95,6 +96,7 @@ public class DiffPreferencesIT extends AbstractDaemonTest {
|
||||
i.renderEntireFile ^= true;
|
||||
i.hideEmptyPane ^= true;
|
||||
i.matchBrackets ^= true;
|
||||
i.lineWrapping ^= true;
|
||||
|
||||
RestResponse r = adminSession.put("/accounts/" + admin.email
|
||||
+ "/preferences.diff", i);
|
||||
@@ -122,6 +124,7 @@ public class DiffPreferencesIT extends AbstractDaemonTest {
|
||||
assertThat(o.renderEntireFile).isEqualTo(i.renderEntireFile);
|
||||
assertThat(o.hideEmptyPane).isEqualTo(i.hideEmptyPane);
|
||||
assertThat(o.matchBrackets).isEqualTo(i.matchBrackets);
|
||||
assertThat(o.lineWrapping).isEqualTo(i.lineWrapping);
|
||||
assertThat(o.ignoreWhitespace).isEqualTo(i.ignoreWhitespace);
|
||||
assertThat(o.theme).isEqualTo(i.theme);
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
assertThat(out.syntaxHighlighting).isTrue();
|
||||
assertThat(out.hideLineNumbers).isNull();
|
||||
assertThat(out.matchBrackets).isTrue();
|
||||
assertThat(out.lineWrapping).isNull();
|
||||
assertThat(out.autoCloseBrackets).isNull();
|
||||
assertThat(out.theme).isEqualTo(Theme.DEFAULT);
|
||||
assertThat(out.keyMapType).isEqualTo(KeyMapType.DEFAULT);
|
||||
@@ -58,6 +59,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
out.syntaxHighlighting = false;
|
||||
out.hideLineNumbers = true;
|
||||
out.matchBrackets = false;
|
||||
out.lineWrapping = true;
|
||||
out.autoCloseBrackets = true;
|
||||
out.theme = Theme.TWILIGHT;
|
||||
out.keyMapType = KeyMapType.EMACS;
|
||||
@@ -100,6 +102,7 @@ public class EditPreferencesIT extends AbstractDaemonTest {
|
||||
assertThat(out.syntaxHighlighting).isNull();
|
||||
assertThat(out.hideLineNumbers).isEqualTo(in.hideLineNumbers);
|
||||
assertThat(out.matchBrackets).isNull();
|
||||
assertThat(out.lineWrapping).isEqualTo(in.lineWrapping);
|
||||
assertThat(out.autoCloseBrackets).isEqualTo(in.autoCloseBrackets);
|
||||
assertThat(out.theme).isEqualTo(in.theme);
|
||||
assertThat(out.keyMapType).isEqualTo(in.keyMapType);
|
||||
|
||||
@@ -56,6 +56,7 @@ public class DiffPreferencesInfo {
|
||||
public Boolean renderEntireFile;
|
||||
public Boolean hideEmptyPane;
|
||||
public Boolean matchBrackets;
|
||||
public Boolean lineWrapping;
|
||||
public Theme theme;
|
||||
public Whitespace ignoreWhitespace;
|
||||
public Boolean retainHeader;
|
||||
@@ -86,6 +87,7 @@ public class DiffPreferencesInfo {
|
||||
i.renderEntireFile = false;
|
||||
i.hideEmptyPane = false;
|
||||
i.matchBrackets = false;
|
||||
i.lineWrapping = false;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class EditPreferencesInfo {
|
||||
public Boolean syntaxHighlighting;
|
||||
public Boolean hideLineNumbers;
|
||||
public Boolean matchBrackets;
|
||||
public Boolean lineWrapping;
|
||||
public Boolean autoCloseBrackets;
|
||||
public Theme theme;
|
||||
public KeyMapType keyMapType;
|
||||
@@ -40,6 +41,7 @@ public class EditPreferencesInfo {
|
||||
i.syntaxHighlighting = true;
|
||||
i.hideLineNumbers = false;
|
||||
i.matchBrackets = true;
|
||||
i.lineWrapping = false;
|
||||
i.autoCloseBrackets = false;
|
||||
i.theme = Theme.DEFAULT;
|
||||
i.keyMapType = KeyMapType.DEFAULT;
|
||||
|
||||
@@ -47,6 +47,7 @@ public class DiffPreferences extends JavaScriptObject {
|
||||
p.skipUncommented(in.skipUncommented);
|
||||
p.skipDeleted(in.skipDeleted);
|
||||
p.matchBrackets(in.matchBrackets);
|
||||
p.lineWrapping(in.lineWrapping);
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ public class DiffPreferences extends JavaScriptObject {
|
||||
p.renderEntireFile = renderEntireFile();
|
||||
p.hideEmptyPane = hideEmptyPane();
|
||||
p.matchBrackets = matchBrackets();
|
||||
p.lineWrapping = lineWrapping();
|
||||
p.theme = theme();
|
||||
p.ignoreWhitespace = ignoreWhitespace();
|
||||
}
|
||||
@@ -141,6 +143,7 @@ public class DiffPreferences extends JavaScriptObject {
|
||||
public final native void skipUncommented(boolean s) /*-{ this.skip_uncommented = s }-*/;
|
||||
public final native void skipDeleted(boolean s) /*-{ this.skip_deleted = s }-*/;
|
||||
public final native void matchBrackets(boolean m) /*-{ this.match_brackets = m }-*/;
|
||||
public final native void lineWrapping(boolean w) /*-{ this.line_wrapping = w }-*/;
|
||||
public final native boolean intralineDifference() /*-{ return this.intraline_difference || false }-*/;
|
||||
public final native boolean showLineEndings() /*-{ return this.show_line_endings || false }-*/;
|
||||
public final native boolean showTabs() /*-{ return this.show_tabs || false }-*/;
|
||||
@@ -157,6 +160,7 @@ public class DiffPreferences extends JavaScriptObject {
|
||||
public final native boolean skipUncommented() /*-{ return this.skip_uncommented || false }-*/;
|
||||
public final native boolean skipDeleted() /*-{ return this.skip_deleted || false }-*/;
|
||||
public final native boolean matchBrackets() /*-{ return this.match_brackets || false }-*/;
|
||||
public final native boolean lineWrapping() /*-{ return this.line_wrapping || false }-*/;
|
||||
|
||||
private final native void setThemeRaw(String i) /*-{ this.theme = i }-*/;
|
||||
private final native void setIgnoreWhitespaceRaw(String i) /*-{ this.ignore_whitespace = i }-*/;
|
||||
|
||||
@@ -31,6 +31,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
p.syntaxHighlighting(in.syntaxHighlighting);
|
||||
p.hideLineNumbers(in.hideLineNumbers);
|
||||
p.matchBrackets(in.matchBrackets);
|
||||
p.lineWrapping(in.lineWrapping);
|
||||
p.autoCloseBrackets(in.autoCloseBrackets);
|
||||
p.theme(in.theme);
|
||||
p.keyMapType(in.keyMapType);
|
||||
@@ -47,6 +48,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
p.syntaxHighlighting = syntaxHighlighting();
|
||||
p.hideLineNumbers = hideLineNumbers();
|
||||
p.matchBrackets = matchBrackets();
|
||||
p.lineWrapping = lineWrapping();
|
||||
p.autoCloseBrackets = autoCloseBrackets();
|
||||
p.theme = theme();
|
||||
p.keyMapType = keyMapType();
|
||||
@@ -71,6 +73,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
public final native void syntaxHighlighting(boolean s) /*-{ this.syntax_highlighting = s }-*/;
|
||||
public final native void hideLineNumbers(boolean s) /*-{ this.hide_line_numbers = s }-*/;
|
||||
public final native void matchBrackets(boolean m) /*-{ this.match_brackets = m }-*/;
|
||||
public final native void lineWrapping(boolean w) /*-{ this.line_wrapping = w }-*/;
|
||||
public final native void autoCloseBrackets(boolean c) /*-{ this.auto_close_brackets = c }-*/;
|
||||
|
||||
public final Theme theme() {
|
||||
@@ -103,6 +106,7 @@ public class EditPreferences extends JavaScriptObject {
|
||||
public final native boolean syntaxHighlighting() /*-{ return this.syntax_highlighting || false }-*/;
|
||||
public final native boolean hideLineNumbers() /*-{ return this.hide_line_numbers || false }-*/;
|
||||
public final native boolean matchBrackets() /*-{ return this.match_brackets || false }-*/;
|
||||
public final native boolean lineWrapping() /*-{ return this.line_wrapping || false }-*/;
|
||||
public final native boolean autoCloseBrackets() /*-{ return this.auto_close_brackets || false }-*/;
|
||||
private final native int get(String n, int d) /*-{ return this.hasOwnProperty(n) ? this[n] : d }-*/;
|
||||
|
||||
|
||||
@@ -80,7 +80,9 @@ limitations under the License.
|
||||
.b { border-left: 1px solid #ddd; }
|
||||
|
||||
.a .diff { background-color: #faa; }
|
||||
.b .diff { background-color: #9f9; }
|
||||
/* Set min-width for lineWrapping to make sure it gets enough width
|
||||
before lineWrapping and to make sure it dosent do a ugly line wrap */
|
||||
.b .diff { background-color: #9f9; min-width: 60em; }
|
||||
.a .intralineBg { background-color: #fee; }
|
||||
.b .intralineBg { background-color: #dfd; }
|
||||
.noIntraline .a .intralineBg { background-color: #faa; }
|
||||
|
||||
@@ -101,6 +101,7 @@ public class PreferencesBox extends Composite {
|
||||
@UiField ToggleButton expandAllComments;
|
||||
@UiField ToggleButton renderEntireFile;
|
||||
@UiField ToggleButton matchBrackets;
|
||||
@UiField ToggleButton lineWrapping;
|
||||
@UiField ListBox theme;
|
||||
@UiField Element modeLabel;
|
||||
@UiField ListBox mode;
|
||||
@@ -193,6 +194,7 @@ public class PreferencesBox extends Composite {
|
||||
manualReview.setValue(prefs.manualReview());
|
||||
expandAllComments.setValue(prefs.expandAllComments());
|
||||
matchBrackets.setValue(prefs.matchBrackets());
|
||||
lineWrapping.setValue(prefs.lineWrapping());
|
||||
setTheme(prefs.theme());
|
||||
|
||||
if (view == null || view.canRenderEntireFile(prefs)) {
|
||||
@@ -492,6 +494,15 @@ public class PreferencesBox extends Composite {
|
||||
prefs.matchBrackets());
|
||||
}
|
||||
|
||||
@UiHandler("lineWrapping")
|
||||
void onLineWrapping(ValueChangeEvent<Boolean> e) {
|
||||
prefs.lineWrapping(e.getValue());
|
||||
view.getCmFromSide(DisplaySide.A).setOption("lineWrapping",
|
||||
prefs.lineWrapping());
|
||||
view.getCmFromSide(DisplaySide.B).setOption("lineWrapping",
|
||||
prefs.lineWrapping());
|
||||
}
|
||||
|
||||
@UiHandler("theme")
|
||||
void onTheme(@SuppressWarnings("unused") ChangeEvent e) {
|
||||
final Theme newTheme = getSelectedTheme();
|
||||
|
||||
@@ -297,6 +297,13 @@ limitations under the License.
|
||||
<g:downFace><ui:msg>On</ui:msg></g:downFace>
|
||||
</g:ToggleButton></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Line Wrapping</ui:msg></th>
|
||||
<td><g:ToggleButton ui:field='lineWrapping'>
|
||||
<g:upFace><ui:msg>Off</ui:msg></g:upFace>
|
||||
<g:downFace><ui:msg>On</ui:msg></g:downFace>
|
||||
</g:ToggleButton></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
|
||||
@@ -641,7 +641,7 @@ public class SideBySide extends Screen {
|
||||
.set("lineNumbers", prefs.showLineNumbers())
|
||||
.set("tabSize", prefs.tabSize())
|
||||
.set("mode", fileSize == FileSize.SMALL ? getContentType(meta) : null)
|
||||
.set("lineWrapping", false)
|
||||
.set("lineWrapping", prefs.lineWrapping())
|
||||
.set("scrollbarStyle", "overlay")
|
||||
.set("styleSelectedText", true)
|
||||
.set("showTrailingSpace", prefs.showWhitespaceErrors())
|
||||
|
||||
@@ -67,6 +67,7 @@ public class EditPreferencesBox extends Composite {
|
||||
@UiField ToggleButton whitespaceErrors;
|
||||
@UiField ToggleButton lineNumbers;
|
||||
@UiField ToggleButton matchBrackets;
|
||||
@UiField ToggleButton lineWrapping;
|
||||
@UiField ToggleButton autoCloseBrackets;
|
||||
@UiField ListBox theme;
|
||||
@UiField ListBox keyMap;
|
||||
@@ -101,6 +102,7 @@ public class EditPreferencesBox extends Composite {
|
||||
whitespaceErrors.setValue(prefs.showWhitespaceErrors());
|
||||
lineNumbers.setValue(prefs.hideLineNumbers());
|
||||
matchBrackets.setValue(prefs.matchBrackets());
|
||||
lineWrapping.setValue(prefs.lineWrapping());
|
||||
autoCloseBrackets.setValue(prefs.autoCloseBrackets());
|
||||
setTheme(prefs.theme());
|
||||
setKeyMapType(prefs.keyMapType());
|
||||
@@ -190,6 +192,14 @@ public class EditPreferencesBox extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("lineWrapping")
|
||||
void onLineWrapping(ValueChangeEvent<Boolean> e) {
|
||||
prefs.lineWrapping(e.getValue());
|
||||
if (view != null) {
|
||||
view.getEditor().setOption("lineWrapping", prefs.lineWrapping());
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("autoCloseBrackets")
|
||||
void onCloseBrackets(ValueChangeEvent<Boolean> e) {
|
||||
prefs.autoCloseBrackets(e.getValue());
|
||||
|
||||
@@ -232,6 +232,13 @@ limitations under the License.
|
||||
<g:downFace><ui:msg>On</ui:msg></g:downFace>
|
||||
</g:ToggleButton></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Line Wrapping</ui:msg></th>
|
||||
<td><g:ToggleButton ui:field='lineWrapping'>
|
||||
<g:upFace><ui:msg>Off</ui:msg></g:upFace>
|
||||
<g:downFace><ui:msg>On</ui:msg></g:downFace>
|
||||
</g:ToggleButton></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Auto Close Brackets</ui:msg></th>
|
||||
<td><g:ToggleButton ui:field='autoCloseBrackets'>
|
||||
|
||||
Reference in New Issue
Block a user