How to add a formatter in Komodo 10?

In Komodo 10, I tried:

Edit > Preferences > Formatters
Click the + sign on the right
In the Name box type the word: Tidy
Language: Perl
Formatter: Other > Generic
Executable: /usr/bin/perltidy

and click OK.

Nothing happens–no formatter is added.

We really need this functionality–our team is expected to tidy our code often. Am I doing something wrong?

Is there a workaround? Can I put this configuration in a config file somewhere until this is fixed?

Komodo IDE, version 10.0.0, build 89159, platform linux-x86_64.
Built on Wed May 11 15:27:38 2016.

Thanks!

I’m not seeing this issue myself. Could you share the contents of your error log after reproducing your issue? You can find your error log at Help > Troubleshooting > View Log File.

Here’s what showed up in the error log:

[2016-05-18 16:23:55,260] [ERROR] formatter-prefs: 
-- EXCEPTION START --
[Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [koIPreferenceRoot.getPref]"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: chrome://komodo/content/formatters/pref-formatters.js :: get_configured_formatters_from_prefset :: line 186"  data: no]
+ toString (function) 3 lines
+ message (string) 'Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [koIPreferenceRoot.getPref]'
+ result (number) 2147549183
+ name (string) 'NS_ERROR_UNEXPECTED'
+ filename (string) 'chrome://komodo/content/formatters/pref-formatters.js'
+ lineNumber (number) 186
+ columnNumber (number) 0
+ inner (object) null
| + data (object) null
| + stack (string) 'get_configured_formatters_from_prefset@chrome://komodo/content/formatters/pref-formatters.js:186:20
'...420 chars
+ location (object) JS frame :: chrome://komodo/content/formatters/pref-formatters.js :: get_configured_formatters_from_prefset :: line 186
| + QueryInterface (function) 3 lines
| + language (number) 2
| + languageName (string) 'JavaScript'
| + filename (string) 'chrome://komodo/content/formatters/pref-formatters.js'
| + name (string) 'get_configured_formatters_from_prefset'
| + lineNumber (number) 186
| + columnNumber (number) 20
| + sourceLine (string) ''
| + caller (object) JS frame :: chrome://komodo/content/formatters/pref-formatters.js :: OnPreferencePageLoading :: line 344
| + formattedStack (string) 'get_configured_formatters_from_prefset@chrome://komodo/content/formatters/pref-formatters.js:186:20
'...420 chars
| + stack
    get_configured_formatters_from_prefset@chrome://komodo/content/formatters/pref-formatters.js:186:20
    OnPreferencePageLoading@chrome://komodo/content/formatters/pref-formatters.js:344:36
    koPrefWindow.prototype.onpageload@chrome://komodo/content/pref/koPrefWindow.js:1048:12
    PrefFormatters_OnLoad@chrome://komodo/content/formatters/pref-formatters.js:381:8
    onload@chrome://komodo/content/formatters/pref-formatters.xul:1:0
-- EXCEPTION END --
[2016-05-18 16:24:27,155] [ERROR] formatter-prefs: 
-- EXCEPTION START --
TypeError: gFormatterConfigurations is null
+ stack
    createNewFormatter@chrome://komodo/content/formatters/pref-formatters.js:251:13
    oncommand@chrome://komodo/content/formatters/pref-formatters.xul:1:1
-- EXCEPTION END --
[2016-05-18 16:24:29,683] [ERROR] formatter-prefs: 
-- EXCEPTION START --
TypeError: gFormattersTreeView is null
+ stack
    OnPreferencePageOK@chrome://komodo/content/formatters/pref-formatters.js:372:9
    koPrefWindow.prototype._doOKHandlers@chrome://komodo/content/pref/koPrefWindow.js:210:26
    koPrefWindow.prototype._onOK@chrome://komodo/content/pref/koPrefWindow.js:265:14
    koPrefWindow.prototype.onApply@chrome://komodo/content/pref/koPrefWindow.js:305:16
    koPrefWindow.prototype.onOK@chrome://komodo/content/pref/koPrefWindow.js:296:16
    doOk@chrome://komodo/content/pref/pref.js:60:10
    oncommand@chrome://komodo/content/pref/pref.xul:1:1
-- EXCEPTION END --

Could you try running this from your Console widget (bottom pane):

ko.prefs.deletePref('configuredFormatters')

This will delete any configured formatters. I suspect your pref somehow got corrupted.

Once that’s done try adding your formatter again. Let me know if that works.

1 Like

Yes, that worked, thanks very much!

We had upgraded from Komodo 9, so perhaps that’s how the pref somehow got corrupted.

It shouldn’t be an issue but it’s a possibility. I’ll add a fail-safe to the code so this doesn’t happen again. Thanks for reporting back :slight_smile: