Set line length to 72 for commit messages
EditScreen and SideBySide2 both allow lines to be longer than 72 characters, but good style is to fit within 72 so that the `git log` command line tool can insert an 8 character wide tab at the start of each line and the message text still fits inside of an 80 column wide terminal. Set the line length to 72 for commit message "files". Change-Id: I0eb2eacb1b28cc0c78eaf1e9f39852ab557d1c7c
This commit is contained in:
@@ -32,6 +32,7 @@ import com.google.gerrit.client.ui.NpIntTextBox;
|
||||
import com.google.gerrit.extensions.common.Theme;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.Patch.ChangeType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
@@ -147,7 +148,13 @@ class PreferencesBox extends Composite {
|
||||
|
||||
setIgnoreWhitespace(prefs.ignoreWhitespace());
|
||||
tabWidth.setIntValue(prefs.tabSize());
|
||||
lineLength.setIntValue(prefs.lineLength());
|
||||
if (Patch.COMMIT_MSG.equals(view.getPath())) {
|
||||
lineLength.setEnabled(false);
|
||||
lineLength.setIntValue(72);
|
||||
} else {
|
||||
lineLength.setEnabled(true);
|
||||
lineLength.setIntValue(prefs.lineLength());
|
||||
}
|
||||
syntaxHighlighting.setValue(prefs.syntaxHighlighting());
|
||||
whitespaceErrors.setValue(prefs.showWhitespaceErrors());
|
||||
showTabs.setValue(prefs.showTabs());
|
||||
|
||||
@@ -73,6 +73,10 @@ limitations under the License.
|
||||
color: #dddd00;
|
||||
}
|
||||
|
||||
.box input.gwt-TextBox:disabled {
|
||||
background-color: #cacaca;
|
||||
}
|
||||
|
||||
.box .gwt-ToggleButton {
|
||||
position: relative;
|
||||
height: 19px;
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.google.gerrit.client.ui.Screen;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
@@ -289,7 +290,7 @@ public class SideBySide2 extends Screen {
|
||||
cmB.refresh();
|
||||
}
|
||||
});
|
||||
setLineLength(prefs.lineLength());
|
||||
setLineLength(Patch.COMMIT_MSG.equals(path) ? 72 : prefs.lineLength());
|
||||
diffTable.refresh();
|
||||
|
||||
if (startLine == 0) {
|
||||
@@ -950,6 +951,10 @@ public class SideBySide2 extends Screen {
|
||||
.inject(cb);
|
||||
}
|
||||
|
||||
String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
DiffPreferences getPrefs() {
|
||||
return prefs;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,8 @@ public class EditScreen extends Screen {
|
||||
cm.adjustHeight(header.getOffsetHeight());
|
||||
cm.on("cursorActivity", updateCursorPosition());
|
||||
cm.extras().showTabs(prefs.showTabs());
|
||||
cm.extras().lineLength(prefs.lineLength());
|
||||
cm.extras().lineLength(
|
||||
Patch.COMMIT_MSG.equals(path) ? 72 : prefs.lineLength());
|
||||
cm.refresh();
|
||||
cm.focus();
|
||||
updateActiveLine();
|
||||
|
||||
Reference in New Issue
Block a user