Fixed insert mode removing first unselected character

(cherry picked from commit fe779d4386)
This commit is contained in:
Paulb23 2016-04-03 14:54:54 +01:00 committed by Rémi Verschelde
parent 22ef9673dd
commit 5f901e2b27
1 changed files with 6 additions and 4 deletions

View File

@ -1625,8 +1625,10 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
k.mod.shift=false; k.mod.shift=false;
} }
// stuff to do when selection is active.. // save here for insert mode, just in case it is cleared in the following section
bool had_selection = selection.active;
// stuff to do when selection is active..
if (selection.active) { if (selection.active) {
if (readonly) if (readonly)
@ -2355,8 +2357,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (readonly) if (readonly)
break; break;
// remove the old character if in insert mode // remove the old character if in insert mode and no selection
if (insert_mode) { if (insert_mode && !had_selection) {
_begin_compex_operation(); _begin_compex_operation();
// make sure we don't try and remove empty space // make sure we don't try and remove empty space
@ -2376,7 +2378,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
_insert_text_at_cursor(chr); _insert_text_at_cursor(chr);
} }
if (insert_mode) { if (insert_mode && !had_selection) {
_end_compex_operation(); _end_compex_operation();
} }
accept_event(); accept_event();