Closed (won't fix)
Project:
Textmate
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Oct 2010 at 09:41 UTC
Updated:
13 Jan 2011 at 22:18 UTC
I'm trying to fix the way Textmate indents arrays, which is wrong for Drupal code style, and drawing a blank :(
The problem is this.
function f() {
// stuff here.
} // note that the closing } is unindented when you hit RETURN after typing the {. This is correct.
function f() {
$a = array(
) // note that the closing ) is places on the next line indented when you hit RETURN after typing the ( -- it should not be.
}
Same problem occurs when pasting array structures:
$a = array(
'x' => array(
'a' => 1,
'b' => 2,
),
// Try to copy the x array here to start a y array, and it indents wrong.
);
Comments
Comment #1
moshe weitzman commentedI'll just agree and say that these indentation snafus are irritating. No idea how to fix.
Comment #2
joachim commentedI was reading this: http://manual.macromates.com/en/appendix
I think the crux of the problem is to do with the ) not magically going to its own line when you hit RETURN within the ().
The problem is not with increaseIndentPattern, inherited from the source bundle. This treats {} and () identically.
I'm not convinced it lies with either of decreaseIndentPattern or indentNextLinePattern, but those are really monstrous regexes which I've not fully figured out yet.
Comment #3
joachim commentedThis is something pretty deep in TextMate, as the inserting a newline behaviour happens for {} even in plain text mode.
Comment #4
psynaptic commentedOk, just tried this with the author of TextMate and we can both get it to work:
I think something has been changed recently which makes this work now. However, it doesn't work well for pasted lines i.e., "indent selection” is not doing the right thing.
Allan says the PHP indent rules need revising as they only provide 2 patterns.
Comment #5
psynaptic commentedOk, so Allan helpfully checked into this and explains:
22:05 allan: it lacks an increaseIndentPattern
22:05 allan: so I guess it just relies on this coming from the Source bundle
22:05 allan: which explains why I am seeing different behavior in TM 1.x and Avian ;)
I have created an issue in the GitHub issue tracker for the PHP bundle so we can track progress on this issue in the correct place:
https://github.com/textmate/php.tmbundle/issues/issue/12
Closing this ticket to clear the queue.