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
commit2603304882a847292fedf38f1edb6d24b99f148e (patch)
treeaa90a33733e5b91fab5a8857b3e07113046b20cb /src/CellBuffer.cxx
parent04477a781d31e2c4e3b10cfe09d7c025fd897421 (diff)
downloadscintilla-mirror-2603304882a847292fedf38f1edb6d24b99f148e.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);