Add preference for line wrapping in diff preferences
Previously in Polygerrit, diff views were always displayed in the width
specified in diff preferences. This change gives the option to wrap
lines instead, which takes precedence over column width (the column
width option is hidden when line wrapping is selected), and fits the
diff view to screen.
The gerrit API already supports the 'lineWrapping' preference so this
change uses that already existing option.
Feature: Issue 4809
Change-Id: I0d9e292739b5910abfd04af63ec4c745bf06e446
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
index 14c2bb5..0816501 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
@@ -87,8 +87,13 @@
.content {
background-color: #fff;
}
+ .full-width {
+ width: 100%;
+ }
.lineNum,
.content {
+ /* Set font size based the user's diff preference. */
+ font-size: var(--font-size, 12px);
vertical-align: top;
white-space: pre;
}
@@ -113,11 +118,7 @@
allows them to shrink. */
max-width: var(--content-width, 80ch);
min-width: var(--content-width, 80ch);
- }
- .content,
- .lineNum {
- /* Set font size based the user's diff preference. */
- font-size: var(--font-size, 12px);
+ width: var(--content-width, 80ch);
}
.content.add .intraline,
.content.add.darkHighlight {
@@ -137,6 +138,10 @@
background-color: #fef;
color: #849;
}
+ .contentText {
+ white-space: pre-wrap;
+ word-wrap: break-word;
+ }
.contextControl gr-button {
display: inline-block;
font-family: var(--monospace-font-family);
@@ -171,10 +176,11 @@
comments="[[_comments]]"
diff="[[_diff]]"
view-mode="[[viewMode]]"
+ line-wrapping="[[lineWrapping]]"
is-image-diff="[[isImageDiff]]"
base-image="[[_baseImage]]"
revision-image="[[_revisionImage]]">
- <table id="diffTable"></table>
+ <table id="diffTable" class$="[[_diffTableClass]]"></table>
</gr-diff-builder>
</gr-diff-highlight>
</gr-diff-selection>