From 2603304882a847292fedf38f1edb6d24b99f148e Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Mon, 16 Feb 2015 17:20:58 +1100 Subject: 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. --- src/CellBuffer.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') 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 #include +#include #include #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); -- cgit v1.2.3