This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | CSS: Indentation reset when pressing enter after starting bracket | ||
---|---|---|---|
Product: | web | Reporter: | emilstenstrom <emilstenstrom> |
Component: | CSS Visual Tools | Assignee: | Jan Stola <jstola> |
Status: | NEW --- | ||
Severity: | blocker | ||
Priority: | P4 | ||
Version: | 6.x | ||
Hardware: | Macintosh | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
emilstenstrom
2009-06-24 14:49:13 UTC
Here's a testcase I think shows the current behavior, resetting the indentation: http://wiki.netbeans.org/TS_60_CSSeditor#section-TS_60_CSSeditor-TestSuiteCodeEditing -- Scroll down to testcase 9. Unfortunately this will be difficult - line/rule is reindented whenever you type opening or closing bracket, that's a feature. The formatting you are using make sense - nesting related rules probably improves readability. The problem is that this rule would have to be added to current CSS formatter and would have to be configurable. Which is probably not too complicated but I cannot see any resource to implement that right now. As far as I'm aware, there are no frequently used indentation styles that have the ending bracket at another level compared to the selector it closes. To me, that means this needs not to be a configuration option, just a change in how the indentation works. When typing a closing bracket: 1) Get the indentation level of the selector of the rule you're in 2) Append that level to each line in the rule, and to the ending bracket This would also be backwards compatible with the only currently supported formatting, when step 1 yields a indentation level of zero. Is this that big of an implementation challenge? It will surely help to push netbeans as a potent CSS Editor. What you are describing is more or less what's happening today. Difference is that if you type '{<press enter here>}' then both opening and closing bracket are reformatted. You can avoid that by typing space first and then enter in between brackets - reformatting of opening bracket is done only if enter was pressed just after opening and just before closing bracket. Re. "Is this that big of an implementation challenge?" - after I completely rewrote formatters for CSS, HTML and JSP in NB6.7 formatter's code is quite flexible and change like you are requesting is straightforward to do. What I meant is that we do not have resources to do the change. Ok, I see what you mean. I'm a decent java programmer myself, maybe I can do that change and submit a patch? Could you point me to the file in question? (or give me a hint of where to start?) Patches are always welcome! Now, I don't want to sound discouraging but because of the size of NetBeans project it might be overwhelming to start - source code repository is big, there is plethora of modules and APIs and as any other project of that size there exist vast amount of documentation in different stages of up-to-date-ness. :-) Saying that, best way to start is to follow http://www.netbeans.org/community/contribute/code.html to get source and build the IDE and read about providing a patch. Then there is css.editor module (in root of your checkout) which is what you are after and there is css.editor/src/org/netbeans/modules/css/editor/CssIndenter.java which is good starting point. Have a look. AbstractIndenter class defined in that module is base class for other formatters (JSP, HTML) and over the time got way more complicated than what's needed for CSS indentation. Actually, writting formatters sounds really easy at the beginning but when you start solving problems of JSP templating snippets in the middle of HTML/CSS statements it gets really really messy. :-) If you just want to have look at the source code then browse it at http://hg.netbeans.org/main/file/tip/css.editor/src/org/netbeans/modules/css/editor/CssIndenter.java |