Komodo has a lot of problems with displaying the indentation correctly, especially with HTML files and big files. The bugs include:
- Displaying spaces instead of tabs when tabs are preferred;
- Displaying tabs and spaces when the tab button is pressed and tabs are preferred;
- Displaying tabs with more whitespaces than is configured
I personally witnessed this with PHP and HTML files and even had to disable the indentation guides as it damaged the readability a lot.
Is this issue known and if so is there a future version when this will be fixed?
Also, which is quite off-topic:
Komodo currently doesn't support loading files from the include_path when it is manually set in files instead of the php.ini, so debugging in IDE doesn't work (e.g. with Zend FW). Is there any news about this?
Thank you
A few others have reported this problem, but we aren't
seeing it here. Part of the problem is while we certainly
use Komodo for our own work, our coding standards favor
spaces over tabs. All the reports have been from
people who prefer tabs.
As soon as I get a test case, I'll work on it.
I'm waiting for one of the PHP experts to comment
on the include_path question.
- Eric
I would also like to report this as a problem. I don't know how your editor decides whether indentation in a file is made with spaces or tabs, but it never seems to get it right. At the very least there should be some way to tell Komodo that it got it wrong.
Possibly there are certain cases where the files in question have both, maybe with some inserted code snippet from another source, so I would like to suggest that your app scan the entire file and see which type of indentation is most prominent (e.g. if there are 500 lines proceeded by tabs, and 3 that are proceeded by spaces, then the file uses tab indentation even if the 3 lines are the first encountered).
I prefer tabs over spaces because when working on opensource projects I want to give editors the choice of using their own tab space, to increase readability. I noticed most PHP developers use indentation of 4 spaces (whether it's a tab or not), I find 3 much more attractive and in my situation I would appreciate if they used tabs instead of hard spaces.
More info on the include_path issue:
I'm using Zend Framework for a project and I have to use set_include_path() for compatibility but by using this doesn't enable suggestions for those files so I assume Komodo isn't including them. And to give you another proof: when running the debugger Komodo says it can't find the files (which would depend on the include_path).
Examples of wrong indentation:
When changing the indentation for a certain language it won't be applied, this doesn't count for global indentation.
Steps: Change indentation for HTML > Create a new HTML file > Use tab to indent
The rest of my files seem to display it fine now so I can give you an example for now but I update this post as soon as it happens again.
--
Isaak Malik
Web Developer
Hello,
Isaak, what do you mean when you say it doesn't display right? You mean if you set tab characters to be 3 characters wide, they don't display that way?
I just created a plain text file, used a few tabs, and it works fine if I ask Komodo to display each tab as 3 or 6 or 30 spaces, using the Edit > Current File Settings dialog.
The problems I noticed are not about how tabs or spaces are displayed, but about Komodo using spaces even though all of the global preference, the language preference and current file preferences say the editor should prefer tabs over spaces! This happens in some cases, I'll try to identify them more clearly and file a bug (or add to current bugs).
Edit: I filed this bug: http://bugs.activestate.com/show_bug.cgi?id=80358
Though it doesn't seem to be a bug after all.
Isaak, is this behaviour (described in the bug report) what's puzzling you?
Hey,
When I said "not displaying correctly" I meant that the custom configuration is not being respected.
E.g. when I change the "spaces per tab" for HTML files to 1 space per tab it still gives me 3 spaces per tab even if I restart Komodo.
And sometimes when I open a big file (mostly mixed HTML + PHP) the tabs preferred setting is completely ignored and spaces are used for the whole file and when pressing the tab key it uses tabs of 1 space.
Your bug description is not really about my issue but about spaces being converted to tabs but it describes functionality which of I don't really understand the use. If I enable "Prefer tabs over spaces" I'd only like to see tabs when I press the tab key and spaces when this is disabled.
--
Isaak Malik
Web Developer
”E.g. when I change the "spaces per tab" for HTML files to 1 space per tab it still gives me 3 spaces per tab even if I restart Komodo.”
It works fine for me. I just need to close the file and reopen it (no need to restart Komodo), and it works. Existing (and new) tab characters are displayed as one-space wide.
If it really doesn't work for you, you should file a bug and describe how to reproduce this bug in detail.
”And sometimes when I open a big file (mostly mixed HTML + PHP) the tabs preferred setting is completely ignored and spaces are used for the whole file and when pressing the tab key it uses tabs of 1 space.”
Do you have the ”Allow file contents to override Tab settings” option checked in Preferences > Editor > Indentation?
Komodo reads the first lines of the file and infers a rule for indentation from that. If the file you opened contains spaces as leading space in the first few lines, and you have this option checked, then it's working as intended. If you don't want file contents to override your Indentation settings, just unckeck this option.
Do you have the ”Allow file contents to override Tab settings” option checked in Preferences > Editor > Indentation?
I bet this was the cause of it, the HTML tabs seem to be working find too now. Thank you for the support :-)
--
Isaak Malik
Web Developer
It's an intentionally simple algorithm, although
it does two things:
1. UseTabs determination:
While looking at no more than the first 100 lines
of a new file:
If any line has a tab in its leading whitespace, assume
we want tabs.
Else if none of the lines start with at least %(pref:tabWidth)
spaces, use the useTabs setting for that language,
otherwise use the global useTabs setting.
Else turn useTabs off.
2. IndentWidth determination:
Also while looking at no more than the first 100 lines
of a new file:
If line i is an indenting line with leading white-space WS1,
and it's followed by an indented line with leading white-space WS2,
and WS2 > WS1:
set indentWidth to WS2 - WS1.
Examples:
if (test) { # indenting line
return 3; # indented line
}
def foo(): # indenting line
return 3 # indented line
Same problem for me as well - this doesn't seem to have been solved yet. I have a simple HTML file with leading tabs (no leading spaces) and when I add a new line in Komodo it indents it with spaces, regardless of my preferences. Currently my preferences are set to:
Auto-Indent Style: Use Smart Indent
Indentation: Prefer tabs over spaces
Language Settings (HTML): Prefer tabs over spaces
I've tried various options and the results is the same: leading spaces instead of tabs.
I've only just started using Komodo and although it looks ideal for what I need, this is a bit of a deal breaker for me. I don't want to have to reformat my code every time I edit a file.
This has been frustrating me since I first decided to switch all development to Komodo (v3) - whenever I need to use it to do HTML or XML I am constantly having to reposition things, whereas Perl and Javascript etc. work perfectly.
I have a test file I just put together, file properties are the following:
Properties
-LANGUAGE: HTML
Editor->Indentation
-Allow file contents to override (UNCHECKED)
-Prefer Tab characters over spaces (CHECKED)
-Number of Spaces per indent (3)
-Width of each Tab character (3)
I just started typing some HTML, without doing any manual repositioning, and this is what I ended up with:
That seems to have fixed it - thank you! You really shouldn't have to fiddle around with those settings for it to work though.
I also noticed that Komodo doesn't use correct indentation with multiple languages in one file, e.g. a PHP file having CSS & HTML code uses the indentation configuration of the PHP language globally.
--
Isaak Malik
Web Developer
@Roobarb: Komodo favors the prefs on a specific file over the general prefs. What do the Editor|Indentation prefs about the file under its properties menu item say?
@Isaak: We're aware that we aren't doing language-specific indentation per region of the file. Could you add a feature request for this?
Thanks,
Eric
The file specific preference is already set to "Prefer tab characters over spaces".
This problem is really the only thing holding me back from using Komodo at the moment. Our standards are for leading tabs only, and never spaces, so I can't just ignore it.
Will do so now.
Thanks Eric.
--
Isaak Malik
Web Developer
On Linux the indentation is even buggier, it seems that 1 space per indentation, whether they are tabs or spaces, is used globally and the indentation settings are completely ignored.
It's really confusing.
--
Isaak Malik
Web Developer
But if you open the file, change the indentation settings,
close the file, and then re-open it, it should have the
new settings.
If this isn't the case, could you send me the file that
is misbehaving, with its name (language extensions are
also used to determine indentation), and I'll see if I
can repro the problem.
Thanks,
Eric
Now that you mentioned the "language extensions" part I checked another PHP file and found out that the issue is only occurring in my file with extension ".tpl.php" and not in a file with extension ".php".
I've sent you the file just in case.
--
Isaak Malik
Web Developer
For example, after I opened the file you sent me (thanks), Komodo opened
it with 1-space indentations, prefer spaces to tabs, but that was because
I had the pref to use the same indentation in the file, and at line 13
Komodo found the "title" tag indented by 1 space under the "head" tag.
However, my settings for Smarty ([Preferences|Editor|Indentation|Language Settings]
was for 4/8, prefer tabs.
There's a feature you might want, but it hasn't been implemented yet, which
is for Komodo to apply different indentation settings to different parts of
a multi-language document, based on the current language. I've logged
a feature request for this at http://bugs.activestate.com/show_bug.cgi?id=81599
- Eric
Does the title tag affect the indentation for the file if the "allow override" setting is enabled?
I see, the .tpl.php extension is considered as a Smarty file which crossed my mind, now that I disabled the Smarty extension indentation works as wanted.
Thanks for creating the bug report but I already had created one here: http://bugs.activestate.com/show_bug.cgi?id=81414
Thanks for the usual good support.
--
Isaak Malik
Web Developer
I was searching the Komodo bugs -- it's better for general bugs
to be entered under Komodo rather than OpenKomodo.
- Eric
Ok, it doesn't matter to me as long as the team knows about it :-)
--
Isaak Malik
Web Developer