fpicker/source/office/autocmpledit.cxx |   25 ++++++++++++++++++++++++-
 fpicker/source/office/autocmpledit.hxx |    2 ++
 sfx2/source/appl/newhelp.cxx           |    1 +
 3 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit b8485b4a4675b5ae2fcee9d44d986415a7165e64
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Apr 14 12:05:49 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Apr 19 15:28:31 2022 +0200

    tdf#148101 don't autocomplete remote files dialog entry on delete/backspace
    
    Change-Id: Ieddb41eb37e7090416a418afeffb76ce0eddf90a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132873
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/fpicker/source/office/autocmpledit.cxx 
b/fpicker/source/office/autocmpledit.cxx
index 5a31c7bdc501..89a2d0b0c245 100644
--- a/fpicker/source/office/autocmpledit.cxx
+++ b/fpicker/source/office/autocmpledit.cxx
@@ -7,21 +7,44 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <vcl/event.hxx>
 #include "autocmpledit.hxx"
 
 AutocompleteEdit::AutocompleteEdit(std::unique_ptr<weld::Entry> xEntry)
     : m_xEntry(std::move(xEntry))
     , m_aChangedIdle("fpicker::AutocompleteEdit m_aChangedIdle")
+    , m_nLastCharCode(0)
 {
     m_xEntry->connect_changed(LINK(this, AutocompleteEdit, ChangedHdl));
+    m_xEntry->connect_key_press(LINK(this, AutocompleteEdit, KeyInputHdl));
 
     m_aChangedIdle.SetInvokeHandler(LINK(this, AutocompleteEdit, 
TryAutoComplete));
 }
 
+IMPL_LINK(AutocompleteEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+    m_nLastCharCode = rKEvt.GetKeyCode().GetCode();
+    return false;
+}
+
 IMPL_LINK_NOARG(AutocompleteEdit, ChangedHdl, weld::Entry&, void)
 {
     m_aChangeHdl.Call(*m_xEntry);
-    m_aChangedIdle.Start(); //launch this to happen on idle after cursor 
position will have been set
+
+    switch (m_nLastCharCode)
+    {
+        case css::awt::Key::DELETE_WORD_BACKWARD:
+        case css::awt::Key::DELETE_WORD_FORWARD:
+        case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
+        case css::awt::Key::DELETE_TO_END_OF_LINE:
+        case KEY_BACKSPACE:
+        case KEY_DELETE:
+            m_aChangedIdle.Stop();
+            break;
+        default:
+            m_aChangedIdle.Start(); //launch this to happen on idle after 
cursor position will have been set
+            break;
+    }
 }
 
 void AutocompleteEdit::AddEntry( const OUString& rEntry )
diff --git a/fpicker/source/office/autocmpledit.hxx 
b/fpicker/source/office/autocmpledit.hxx
index bfb2ee096a63..3eb79eb14aa6 100644
--- a/fpicker/source/office/autocmpledit.hxx
+++ b/fpicker/source/office/autocmpledit.hxx
@@ -22,7 +22,9 @@ private:
     std::vector<OUString> m_aMatching;
     Idle m_aChangedIdle;
     Link<weld::Entry&, void> m_aChangeHdl;
+    sal_uInt16 m_nLastCharCode;
 
+    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
     DECL_LINK(ChangedHdl, weld::Entry&, void);
     DECL_LINK(TryAutoComplete, Timer*, void);
 
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 9312a83ccd04..b3b7483bb29a 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -475,6 +475,7 @@ IMPL_LINK_NOARG(IndexTabPage_Impl, EntryChangeHdl, 
weld::Entry&, void)
         case css::awt::Key::DELETE_TO_END_OF_LINE:
         case KEY_BACKSPACE:
         case KEY_DELETE:
+            aAutoCompleteIdle.Stop();
             break;
         default:
             aAutoCompleteIdle.Start();

Reply via email to