From 9382bd3292230f392a3a84cc8ceeff9f723e69c2 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 21 Jul 2013 23:49:09 +0000 Subject: [PATCH] [BUG_FIXED] (Author: Andreas Jonsson) Bugfix: begin/end selection when the text is not constant. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1080 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/NppNotification.cpp | 1 + .../src/ScitillaComponent/ScintillaEditView.cpp | 13 +++++++++++++ .../src/ScitillaComponent/ScintillaEditView.h | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 1ffe334f..13388ea2 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -49,6 +49,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) static bool prevWasEdit = false; if (notification->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT)) { + _pEditView->updateBeginEndSelectPosition(notification->modificationType & SC_MOD_INSERTTEXT, notification->position, notification->length); prevWasEdit = true; _linkTriggered = true; ::InvalidateRect(notifyView->getHSelf(), NULL, TRUE); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 434acb97..c10e45ce 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2057,6 +2057,19 @@ void ScintillaEditView::beginOrEndSelect() } } +void ScintillaEditView::updateBeginEndSelectPosition(const bool is_insert, const int position, const int length) +{ + if(_beginSelectPosition != -1 && position < _beginSelectPosition - 1) + { + if(is_insert) + _beginSelectPosition += length; + else + _beginSelectPosition -= length; + + assert(_beginSelectPosition >= 0); + } +} + void ScintillaEditView::marginClick(int position, int modifiers) { int lineClick = int(execute(SCI_LINEFROMPOSITION, position, 0)); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index b51748b7..91472ed8 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -335,7 +335,8 @@ public: bool hasMarginShowed(int witchMarge) { return (execute(SCI_GETMARGINWIDTHN, witchMarge, 0) != 0); }; - + + void updateBeginEndSelectPosition(const bool is_insert, const int position, const int length); void marginClick(int position, int modifiers); void setMakerStyle(folderStyle style) {