
When a diff request includes an ignore-whitespace level, the same diff content is returned, but a number of diff chunks are marked as "common" with the understanding that those chunks only contain the kind of whitespace that can be ignored. Thus, actually ignoring these chunks is up to the frontend. In this commit, support is added for editing the preferred whitespace level, and the preferred level is included in diff requests. When a diff is loaded with an ignore-whitespace level, gr-diff-host transforms the marked deltas into shared chunks. In this way, when the transformed diff is passed down into gr-diff, it can be rendered like normal and the unwanted whitespace deltas do not appear. To transform a diff with chunks to be ignored, the strategy is as follows. If a marked delta chunk has revision (a right-side), then it's converted to a shared chunk where both sides are made up of the revision content. (If a marked delta chunk has no revision content, it's merely omitted.) Finally, adjacent shared chunks that result from modifying the marked chunks are merged together so that gr-diff will properly position context-control barriers. Feature: Issue 6198 Change-Id: I1e4cc1075edf34f5ce87ee6bfc2cf415a3b98d94
174 lines
6.0 KiB
HTML
174 lines
6.0 KiB
HTML
<!--
|
|
@license
|
|
Copyright (C) 2016 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
|
<link rel="import" href="../../../bower_components/iron-input/iron-input.html">
|
|
<link rel="import" href="../../shared/gr-button/gr-button.html">
|
|
<link rel="import" href="../../shared/gr-overlay/gr-overlay.html">
|
|
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
|
<link rel="import" href="../../shared/gr-storage/gr-storage.html">
|
|
<link rel="import" href="../../../styles/shared-styles.html">
|
|
|
|
<dom-module id="gr-diff-preferences">
|
|
<template>
|
|
<style include="shared-styles">
|
|
:host {
|
|
display: block;
|
|
}
|
|
:host([disabled]) {
|
|
opacity: .5;
|
|
pointer-events: none;
|
|
}
|
|
input,
|
|
select {
|
|
font: inherit;
|
|
}
|
|
input[type="number"] {
|
|
width: 4em;
|
|
}
|
|
.header,
|
|
.actions {
|
|
padding: 1em 1.5em;
|
|
}
|
|
.header,
|
|
.mainContainer,
|
|
.actions {
|
|
background-color: var(--dialog-background-color);
|
|
}
|
|
.header {
|
|
border-bottom: 1px solid var(--border-color);
|
|
font-family: var(--font-family-bold);
|
|
}
|
|
.mainContainer {
|
|
padding: 1em 0;
|
|
}
|
|
.pref {
|
|
align-items: center;
|
|
display: flex;
|
|
padding: .35em 1.5em;
|
|
width: 25em;
|
|
}
|
|
.pref:hover {
|
|
background-color: var(--hover-background-color);
|
|
}
|
|
.pref label {
|
|
cursor: pointer;
|
|
flex: 1;
|
|
}
|
|
.actions {
|
|
border-top: 1px solid var(--border-color);
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
}
|
|
gr-button {
|
|
margin-left: 1em;
|
|
}
|
|
</style>
|
|
<gr-overlay id="prefsOverlay" with-backdrop>
|
|
<div class="header">
|
|
Diff View Preferences
|
|
</div>
|
|
<div class="mainContainer">
|
|
<div class="pref">
|
|
<label for="contextSelect">Context</label>
|
|
<select id="contextSelect" on-change="_handleContextSelectChange">
|
|
<option value="3">3 lines</option>
|
|
<option value="10">10 lines</option>
|
|
<option value="25">25 lines</option>
|
|
<option value="50">50 lines</option>
|
|
<option value="75">75 lines</option>
|
|
<option value="100">100 lines</option>
|
|
<option value="-1">Whole file</option>
|
|
</select>
|
|
</div>
|
|
<div class="pref">
|
|
<label for="lineWrappingInput">Fit to screen</label>
|
|
<input
|
|
is="iron-input"
|
|
type="checkbox"
|
|
id="lineWrappingInput"
|
|
on-tap="_handlelineWrappingTap">
|
|
</div>
|
|
<div class="pref" id="columnsPref">
|
|
<label for="columnsInput">Diff width</label>
|
|
<input is="iron-input" type="number" id="columnsInput"
|
|
prevent-invalid-input
|
|
allowed-pattern="[0-9]"
|
|
bind-value="{{_newPrefs.line_length}}">
|
|
</div>
|
|
<div class="pref">
|
|
<label for="tabSizeInput">Tab width</label>
|
|
<input is="iron-input" type="number" id="tabSizeInput"
|
|
prevent-invalid-input
|
|
allowed-pattern="[0-9]"
|
|
bind-value="{{_newPrefs.tab_size}}">
|
|
</div>
|
|
<div class="pref" hidden$="[[!_newPrefs.font_size]]">
|
|
<label for="fontSizeInput">Font size</label>
|
|
<input is="iron-input" type="number" id="fontSizeInput"
|
|
prevent-invalid-input
|
|
allowed-pattern="[0-9]"
|
|
bind-value="{{_newPrefs.font_size}}">
|
|
</div>
|
|
<div class="pref">
|
|
<label for="showTabsInput">Show tabs</label>
|
|
<input is="iron-input" type="checkbox" id="showTabsInput"
|
|
on-tap="_handleShowTabsTap">
|
|
</div>
|
|
<div class="pref">
|
|
<label for="showTrailingWhitespaceInput">
|
|
Show trailing whitespace</label>
|
|
<input is="iron-input" type="checkbox"
|
|
id="showTrailingWhitespaceInput"
|
|
on-tap="_handleShowTrailingWhitespaceTap">
|
|
</div>
|
|
<div class="pref">
|
|
<label for="syntaxHighlightInput">Syntax highlighting</label>
|
|
<input is="iron-input" type="checkbox" id="syntaxHighlightInput"
|
|
on-tap="_handleSyntaxHighlightTap">
|
|
</div>
|
|
<div class="pref">
|
|
<label for="automaticReviewInput">Automatically mark viewed files reviewed</label>
|
|
<input
|
|
is="iron-input"
|
|
id="automaticReviewInput"
|
|
type="checkbox"
|
|
on-tap="_handleAutomaticReviewTap">
|
|
</div>
|
|
<div class="pref">
|
|
<label for="ignoreWhitespace">Ignore Whitespace</label>
|
|
<select id="ignoreWhitespace" on-change="_handleIgnoreWhitespaceChange">
|
|
<option value="IGNORE_NONE">None</option>
|
|
<option value="IGNORE_TRAILING">Trailing</option>
|
|
<option value="IGNORE_LEADING_AND_TRAILING">Leading & trailing</option>
|
|
<option value="IGNORE_ALL">All</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="actions">
|
|
<gr-button id="cancelButton" link on-tap="_handleCancel">
|
|
Cancel</gr-button>
|
|
<gr-button id="saveButton" link primary on-tap="_handleSave">
|
|
Save</gr-button>
|
|
</div>
|
|
</gr-overlay>
|
|
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
|
<gr-storage id="storage"></gr-storage>
|
|
</template>
|
|
<script src="gr-diff-preferences.js"></script>
|
|
</dom-module>
|