KTextEditor
kateindentdetecter.cpp
79 if (spacesDiff > 0 && 0 <= bSpacesCnt - 1 && bSpacesCnt - 1 < a.length() && bSpacesCnt < b.length()) {
98KateIndentDetecter::Result KateIndentDetecter::detect(int defaultTabSize, bool defaultInsertSpaces)
103 int linesIndentedWithTabsCount = 0; // number of lines that contain at least one tab in indentation
104 int linesIndentedWithSpacesCount = 0; // number of lines that contain only spaces in indentation
107 int previousLineIndentation = 0; // index at which latest line contained the first non-whitespace char
109 constexpr int ALLOWED_TAB_SIZE_GUESSES[] = {2, 4, 6, 8, 3, 5, 7}; // prefer even guesses for `tabSize`, limit to [2, 8].
112 int spacesDiffCount[MAX_ALLOWED_TAB_SIZE_GUESS + 1] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; // `tabSize` scores
120 int currentLineIndentation = 0; // index at which `currentLineText` contains the first non-whitespace char
149 tmp = spacesDiff(previousLineText, previousLineIndentation, currentLineText, currentLineIndentation);
152 // if defaultInsertSpaces === true && the spaces count == tabSize, we may want to count it as valid indentation
187 // prefer multiples of two, if ever found one, see bug 474505 and autotests/input/indent_detect/bogus7spaces.md
197 if (tabSize == 4 && spacesDiffCount[4] > 0 && spacesDiffCount[2] > 0 && spacesDiffCount[2] >= spacesDiffCount[4] / 2) {
Backend of KTextEditor::Document related public KTextEditor interfaces.
Definition katedocument.h:68
const QChar at(qsizetype position) const const
qsizetype length() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.