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 /src | |
| parent | 162aa0cad54f2e6b26cb7f5b8e78c3db0874c0a9 (diff) | |
| download | scintilla-mirror-ccc64662f64347910e7366914f75f03b51e2710b.tar.gz | |
Patch from Gene Barry to avoid movement of markers when calling
ConvertLineEnds.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Document.cxx | 47 | 
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();  } | 
