diff options
| author | nyamatongwe <unknown> | 2005-02-04 10:59:54 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2005-02-04 10:59:54 +0000 | 
| commit | ec099a9f83f1eb631cee326a02c653b79bdc72a8 (patch) | |
| tree | 80402e60d9b4f9a417266f788abf4459d05f8512 /src | |
| parent | 58bd4b55159522d4fc1476bf6d515e9c995ed604 (diff) | |
| download | scintilla-mirror-ec099a9f83f1eb631cee326a02c653b79bdc72a8.tar.gz | |
Avoid performing any actions when inserting a 0 length string.
Added an undo action around setting line indenation so it is
undone together.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Document.cxx | 20 | 
1 files changed, 12 insertions, 8 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 27363d6e9..87a101822 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -524,15 +524,17 @@ bool Document::InsertString(int position, const char *s) {   */  bool Document::InsertString(int position, const char *s, size_t insertLength) {  	bool changed = false; -	char *sWithStyle = new char[insertLength * 2]; -	if (sWithStyle) { -		for (size_t i = 0; i < insertLength; i++) { -			sWithStyle[i*2] = s[i]; -			sWithStyle[i*2 + 1] = 0; +	if (insertLength > 0) { +		char *sWithStyle = new char[insertLength * 2]; +		if (sWithStyle) { +			for (size_t i = 0; i < insertLength; i++) { +				sWithStyle[i*2] = s[i]; +				sWithStyle[i*2 + 1] = 0; +			} +			changed = InsertStyledString(position*2, sWithStyle, +				static_cast<int>(insertLength*2)); +			delete []sWithStyle;  		} -		changed = InsertStyledString(position*2, sWithStyle, -			static_cast<int>(insertLength*2)); -		delete []sWithStyle;  	}  	return changed;  } @@ -611,8 +613,10 @@ void Document::SetLineIndentation(int line, int indent) {  		CreateIndentation(linebuf, sizeof(linebuf), indent, tabInChars, !useTabs);  		int thisLineStart = LineStart(line);  		int indentPos = GetLineIndentPosition(line); +		BeginUndoAction();  		DeleteChars(thisLineStart, indentPos - thisLineStart);  		InsertString(thisLineStart, linebuf); +		EndUndoAction();  	}  } | 
