[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - sc/source
Dennis Francis (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 25 18:40:04 UTC 2021
sc/source/ui/app/inputhdl.cxx | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
New commits:
commit a386f785560f97469b94c3e2800e3eb79df05154
Author: Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Tue May 4 13:28:41 2021 +0530
Commit: Dennis Francis <dennis.francis at collabora.com>
CommitDate: Tue May 25 20:39:32 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.francis at collabora.com>
(cherry picked from commit f8039c6d645acb015a6c4e45000bbfd1311bfea3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116082
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 53065ba49f15..e2d0da10537e 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;
}
}
@@ -1965,12 +1972,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
More information about the Libreoffice-commits
mailing list