Commit d70b174a authored by Igor Kushnir's avatar Igor Kushnir
Browse files

Disable Reformat actions when no formatting style is configured

This can happen in a new session when source formatters are not yet
configured, or when the user installs kdev-python but does not configure
the source formatter for Python language.

In this case the actions are useless and best disabled: when the style
name is empty, triggering Reformat (Source|Line) action does not modify
the code, and the following warning appears in KDevelop's output:
kdevelop.plugins.customscript: Empty contents for style "" for indent plugin
parent 411b415a
......@@ -516,10 +516,15 @@ void SourceFormatterController::updateFormatTextAction()
const auto style = styleForUrl(url, mime);
const auto styleName =;
if (styleName.isEmpty()) {
return disabled; // A valid style's name is never empty => no style is configured for url.
auto styleCaption = style.caption();
if (styleCaption.isEmpty()) {
// This could be an incomplete predefined style, for which only the name is stored in config.
styleCaption = formatter->predefinedStyle(;
styleCaption = formatter->predefinedStyle(styleName).caption();
return std::tuple { true, formatter->caption(), std::move(styleCaption) };
Supports Markdown
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