aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/CellBuffer.cxx
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2015-02-16 17:20:58 +1100
committerNeil Hodgson <nyamatongwe@gmail.com>2015-02-16 17:20:58 +1100
commit290d6b8e2b36149e52f6d95ffe193797870de65a (patch)
tree99160a661ecb3a7c5aa6afa8611afd685f9185b6 /src/CellBuffer.cxx
parent8ad87a8f8ce2aca54714f7f2735638ac5d14d830 (diff)
downloadscintilla-mirror-290d6b8e2b36149e52f6d95ffe193797870de65a.tar.gz
Fix bugs caused by deleting text with undo collection off when entering IME composition mode.
This deleted text isn't in the undo history and it isn't in the document so can never be recovered so makes it impossible to correctly perform undo. Add logging for unexpected situations and throw an exception when undo can't be performed. Ensure empty marked text range is always in canonical (NSNotFound,0) form.
Diffstat (limited to 'src/CellBuffer.cxx')
-rw-r--r--src/CellBuffer.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index a770dc335..dfa1350c0 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdarg.h>
+#include <stdexcept>
#include <algorithm>
#include "Platform.h"
@@ -786,6 +787,10 @@ const Action &CellBuffer::GetUndoStep() const {
void CellBuffer::PerformUndoStep() {
const Action &actionStep = uh.GetUndoStep();
if (actionStep.at == insertAction) {
+ if (substance.Length() < actionStep.lenData) {
+ throw std::runtime_error(
+ "CellBuffer::PerformUndoStep: deletion must be less than document length.");
+ }
BasicDeleteChars(actionStep.position, actionStep.lenData);
} else if (actionStep.at == removeAction) {
BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);