Commit e86c5a72 authored by Thomas Schöps's avatar Thomas Schöps Committed by Milian Wolff

Clang CodeCompletion: No auto-completion for numbers

Summary: When typing a number, code-completion is undesirable in my opinion, since most likely no completion item applies and it only distracts, obstructs the view, or is triggered accidentally. Thus, this patch prevents code completion from automatically getting triggered for numbers. It does not cover all cases (code completion will still show something for floating-point numbers that start with a dot, such as .1f) but should cover the most common cases. Manual completion with Ctrl+Space is still possible.

Test Plan: Tested manually.

Reviewers: #kdevelop, mwolff

Reviewed By: #kdevelop, mwolff

Subscribers: mwolff, brauch, kdevelop-devel

Tags: #kdevelop

Differential Revision: https://phabricator.kde.org/D17915
parent 7e4294a8
......@@ -195,6 +195,10 @@ bool ClangCodeCompletionModel::shouldStartCompletion(KTextEditor::View* view, co
if (noCompletionAfter.contains(lastChar)) {
return false;
}
const auto wordAtPosition = view->document()->wordAt(position);
if (!wordAtPosition.isEmpty() && wordAtPosition.at(0).isDigit()) {
return false;
}
// also show include path completion after dashes
if (userInsertion && lastChar == QLatin1Char('-') && includePathCompletionRequired(view->document()->line(position.line()))) {
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment