aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2004-08-03 01:38:26 +0000
committernyamatongwe <devnull@localhost>2004-08-03 01:38:26 +0000
commitef237e0c549ca95e27ecced10cecfc14b2233090 (patch)
tree2cff2d9edfa03dac086fd97a92a3805cc08306dc /src
parentf14a8926766be1904f7f64487c4914611e2e6f2b (diff)
downloadscintilla-mirror-ef237e0c549ca95e27ecced10cecfc14b2233090.tar.gz
Patch from Gene Barry to avoid movement of markers when calling
ConvertLineEnds.
Diffstat (limited to 'src')
-rw-r--r--src/Document.cxx47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index c06397fa8..e8d88cc87 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -684,41 +684,40 @@ void Document::Indent(bool forwards, int lineBottom, int lineTop) {
void Document::ConvertLineEnds(int eolModeSet) {
BeginUndoAction();
+
for (int pos = 0; pos < Length(); pos++) {
if (cb.CharAt(pos) == '\r') {
- if (cb.CharAt(pos + 1) == '\n') {
- if (eolModeSet != SC_EOL_CRLF) {
- DeleteChars(pos, 2);
- if (eolModeSet == SC_EOL_CR)
- InsertString(pos, "\r", 1);
- else
- InsertString(pos, "\n", 1);
+ if (cb.CharAt(pos + 1) == '\n') {
+ // CRLF
+ if (eolModeSet == SC_EOL_CR) {
+ DeleteChars(pos + 1, 1); // Delete the LF
+ } else if (eolModeSet == SC_EOL_LF) {
+ DeleteChars(pos, 1); // Delete the CR
} else {
pos++;
}
- } else {
- if (eolModeSet != SC_EOL_CR) {
- DeleteChars(pos, 1);
- if (eolModeSet == SC_EOL_CRLF) {
- InsertString(pos, "\r\n", 2);
- pos++;
- } else {
- InsertString(pos, "\n", 1);
- }
- }
- }
- } else if (cb.CharAt(pos) == '\n') {
- if (eolModeSet != SC_EOL_LF) {
- DeleteChars(pos, 1);
+ } else {
+ // CR
if (eolModeSet == SC_EOL_CRLF) {
- InsertString(pos, "\r\n", 2);
+ InsertString(pos + 1, "\n", 1); // Insert LF
pos++;
- } else {
- InsertString(pos, "\r", 1);
+ } else if (eolModeSet == SC_EOL_LF) {
+ InsertString(pos, "\n", 1); // Insert LF
+ DeleteChars(pos + 1, 1); // Delete CR
}
}
+ } else if (cb.CharAt(pos) == '\n') {
+ // LF
+ if (eolModeSet == SC_EOL_CRLF) {
+ InsertString(pos, "\r", 1); // Insert CR
+ pos++;
+ } else if (eolModeSet == SC_EOL_CR) {
+ InsertString(pos, "\r", 1); // Insert CR
+ DeleteChars(pos + 1, 1); // Delete LF
+ }
}
}
+
EndUndoAction();
}