sc/source/ui/app/inputhdl.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
New commits: commit f8039c6d645acb015a6c4e45000bbfd1311bfea3 Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Tue May 4 13:28:41 2021 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Thu May 13 16:23:21 2021 +0200 tdf#142214: show autocompletion only if there is... ...exactly one match Picking one from many matches by any logic requires the user to pay attention to the auto completed match and see if it the one they wanted. Instead show autocomplete only when there is exactly one match with what the user has already typed. Change-Id: If8f7e59fe905d3d472a5a5795f96374ec2d1a6e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115457 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 9085f28638c3..3082cdb83455 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -163,10 +163,13 @@ OUString getExactMatch(const ScTypedCaseStrSet& rDataSet, const OUString& rStrin ScTypedCaseStrSet::const_iterator findTextAll( const ScTypedCaseStrSet& rDataSet, ScTypedCaseStrSet::const_iterator const & itPos, - const OUString& rStart, ::std::vector< OUString > &rResultVec, bool bBack) + const OUString& rStart, ::std::vector< OUString > &rResultVec, bool bBack, size_t nMax = 0) { rResultVec.clear(); // clear contents + if (!rDataSet.size()) + return rDataSet.end(); + size_t nCount = 0; ScTypedCaseStrSet::const_iterator retit; if ( bBack ) // Backwards @@ -217,6 +220,8 @@ ScTypedCaseStrSet::const_iterator findTextAll( std::advance(retit, nPos); } ++nCount; + if (nMax > 0 && nCount >= nMax) + break; } } else // Forwards @@ -249,6 +254,8 @@ ScTypedCaseStrSet::const_iterator findTextAll( if ( nCount == 0 ) retit = it; // remember first match iterator ++nCount; + if (nMax > 0 && nCount >= nMax) + break; } } @@ -1963,12 +1970,16 @@ void ScInputHandler::UseColData() // When typing if (aText.isEmpty()) return; + std::vector< OUString > aResultVec; OUString aNew; miAutoPosColumn = pColumnData->end(); - miAutoPosColumn = findText(*pColumnData, miAutoPosColumn, aText, aNew, false); - if (miAutoPosColumn == pColumnData->end()) + miAutoPosColumn = findTextAll(*pColumnData, miAutoPosColumn, aText, aResultVec, false, 2); + bool bShowCompletion = (aResultVec.size() == 1); + if (!bShowCompletion) return; + assert(miAutoPosColumn != pColumnData->end()); + aNew = aResultVec[0]; // Strings can contain line endings (e.g. due to dBase import), // which would result in multiple paragraphs here, which is not desirable. //! Then GetExactMatch doesn't work either _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits