Commit 729c0ac8 authored by Igor Kushnir's avatar Igor Kushnir Committed by Nicolás Alvarez
Browse files

Print a clear warning when indentation sample is missing

Currently KDevelop does some useless work, then prints an unrelated and
confusing warning: "indent returned empty text for style ..."

Steps to make KDevelop print this warning:
1. Check "Override Kate Indentation Mode" and/or "Add Kate Modeline"
   checkbox in Source Formatter configuration.
2. Configure any Custom Script Formatter style for a language, e.g. C++.
3. Open a document in the configured language, e.g. a .cpp file.
4. Ensure that no text is selected, then trigger Reformat Source action.

Note that !273
implements ClangSupport::indentationSample(). But other language plugins
don't override this function. Once !273 is merged, this message will
still be printed for Python documents.
parent 8c2606c1
Pipeline #95971 passed with stage
in 11 minutes and 17 seconds
......@@ -413,8 +413,13 @@ QStringList CustomScriptPlugin::computeIndentationFromSample(const QUrl& url) co
if (languages.isEmpty()) {
return ret;
}
QString sample = languages[0]->indentationSample();
const auto& language = *languages.constFirst();
const auto sample = language.indentationSample();
if (sample.isEmpty()) {
qCWarning(CUSTOMSCRIPT) << "Cannot compute indentation because of missing indentation sample in language plugin"
<< language.name();
return ret;
}
QString formattedSample = formatSource(sample, url, QMimeDatabase().mimeTypeForUrl(url), QString(), QString());
const QStringList lines = formattedSample.split(QLatin1Char('\n'));
......
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