Preserve line-endings in inline editing

When a file with Windows line endings was edited all the line ending
characters were replaced by the Unix style line endings '\n'. This
generated artificially large diffs as all lines had a changed line
ending.

To solve the issue this change automatically detects the line-ending
type and preserves line-endings by setting an option parameter of the
editor called "lineSeperator".

Bug: issue 3345
Change-Id: If7e2ed3b3327c7734175f1d3e864deaae2401a8f
This commit is contained in:
LeiSun
2017-06-23 17:18:56 +02:00
committed by David Pursehouse
parent e6976dc2b9
commit 262f893349

View File

@@ -558,7 +558,7 @@ public class EditScreen extends Screen {
mode = ModeInfo.findMode(content.getContentType(), path); mode = ModeInfo.findMode(content.getContentType(), path);
} }
} }
mv = MergeView.create(editor, Configuration.create() Configuration cfg = Configuration.create()
.set("autoCloseBrackets", prefs.autoCloseBrackets()) .set("autoCloseBrackets", prefs.autoCloseBrackets())
.set("cursorBlinkRate", prefs.cursorBlinkRate()) .set("cursorBlinkRate", prefs.cursorBlinkRate())
.set("cursorHeight", 0.85) .set("cursorHeight", 0.85)
@@ -574,7 +574,13 @@ public class EditScreen extends Screen {
.set("styleSelectedText", true) .set("styleSelectedText", true)
.set("tabSize", prefs.tabSize()) .set("tabSize", prefs.tabSize())
.set("theme", prefs.theme().name().toLowerCase()) .set("theme", prefs.theme().name().toLowerCase())
.set("value", "")); .set("value", "");
if (editContent.contains("\r\n")) {
cfg.set("lineSeparator", "\r\n");
}
mv = MergeView.create(editor, cfg);
cmBase = mv.leftOriginal(); cmBase = mv.leftOriginal();
cmBase.getWrapperElement().addClassName(style.base()); cmBase.getWrapperElement().addClassName(style.base());