diff options
author | nyamatongwe <unknown> | 2004-08-03 01:38:26 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2004-08-03 01:38:26 +0000 |
commit | ccc64662f64347910e7366914f75f03b51e2710b (patch) | |
tree | 2cff2d9edfa03dac086fd97a92a3805cc08306dc | |
parent | 162aa0cad54f2e6b26cb7f5b8e78c3db0874c0a9 (diff) | |
download | scintilla-mirror-ccc64662f64347910e7366914f75f03b51e2710b.tar.gz |
Patch from Gene Barry to avoid movement of markers when calling
ConvertLineEnds.
-rw-r--r-- | doc/ScintillaHistory.html | 1 | ||||
-rw-r--r-- | src/Document.cxx | 47 |
2 files changed, 24 insertions, 24 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 835269b63..bcee196db 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -175,6 +175,7 @@ <li>Hadar Raz</li> <li>Herr Pfarrer</li> <li>Ben Key</li> + <li>Gene Barry</li> </ul> <p> Images used in GTK+ version 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(); } |