summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2021-05-04 13:28:41 +0530
committerDennis Francis <dennis.francis@collabora.com>2021-05-25 20:39:32 +0200
commita386f785560f97469b94c3e2800e3eb79df05154 (patch)
tree5965869642fbb1a732b305db33a7ad81fc0c2b2a /sc
parentf4635b01d0c1dbfca5031a73fe23bad0859671ca (diff)
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@collabora.com> (cherry picked from commit f8039c6d645acb015a6c4e45000bbfd1311bfea3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116082 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/app/inputhdl.cxx17
1 files changed, 14 insertions, 3 deletions
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