From 961e6dab88a8a5d504dc16ed4a9b165b83fb3c60 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 20 Jun 2014 10:44:14 -0700 Subject: [PATCH] Select the last token when double-clicking past the end of the text in the edit box --- src/subs_edit_ctrl.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/subs_edit_ctrl.cpp b/src/subs_edit_ctrl.cpp index 7eb00380a..4934afbc7 100644 --- a/src/subs_edit_ctrl.cpp +++ b/src/subs_edit_ctrl.cpp @@ -373,11 +373,18 @@ void SubsTextEditCtrl::OnContextMenu(wxContextMenuEvent &event) { } void SubsTextEditCtrl::OnDoubleClick(wxStyledTextEvent &evt) { - auto bounds = GetBoundsOfWordAtPosition(evt.GetPosition()); - if (bounds.second != 0) - SetSelection(bounds.first, bounds.first + bounds.second); - else - evt.Skip(); + int pos = evt.GetPosition(); + if (pos == -1 && !tokenized_line.empty()) { + auto tok = tokenized_line.back(); + SetSelection(line_text.size() - tok.length, line_text.size()); + } + else { + auto bounds = GetBoundsOfWordAtPosition(evt.GetPosition()); + if (bounds.second != 0) + SetSelection(bounds.first, bounds.first + bounds.second); + else + evt.Skip(); + } } void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) {