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.

Bug 248345

Summary: Wrong indentation of custom elements
Product: web Reporter: Vladimir Riha <vriha>
Component: HTML EditorAssignee: Milutin Kristofic <mkristofic>
Status: NEW ---    
Severity: normal CC: avandecreme, ppisl, rsvitanic
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description Vladimir Riha 2014-11-02 17:06:18 UTC
I have following HTML

<!DOCTYPE html>
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="styles/style.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <h2>Your message:</h2>
        <textarea rows="5" cols="40" data-bind="textInput: currentMessage">
            
        </textarea><br/>
        <button type="button" data-bind="click: sendText">Send</button>

        <h2>Messages:</h2>
    <messages params="messages: messages"></messages>
    <script src="libs/knockout/knockout-min.js" type="text/javascript"></script>
    <script src="src.js" type="text/javascript"></script>
</body>
</html>



and following JS:
        ko.components.register('messages', {
            viewModel: function (params) {
                this.messages = ko.observable(params.messages || []);
            },
            template: '<table><tbody data-bind="foreach: messages"><tr><td> <span data-bind="text: msg"></span>:<span data-bind="text: value"></span></td></tr></tbody></table>'
        });


Please notice the wrong indentation of <messages> element in the HTML code, it should be on same level as the <h2> above.

Thanks


Product Version: NetBeans IDE Dev (Build web-main-1474-on-20141031)
Java: 1.8.0_20; Java HotSpot(TM) Client VM 25.20-b23
Runtime: Java(TM) SE Runtime Environment 1.8.0_20-b26
System: Linux version 3.13.0-35-generic running on i386; UTF-8; en_US (nb)
Comment 1 Roman Svitanic 2014-11-03 07:49:36 UTC
This happens only in case if custom element is placed directly inside the body element. If it's placed in e.g., div, then formatting is correct.

Same issue applies to the user-defined HTML custom elements:
e.g., write <test-element></test-element> inside the body and click offered hint, select "Add element "test-element" to the projects custom elements", then reformat the document.

It seems to be more general issue with indentation. Reassigning to HTML editor for evaluation. Thanks.
Comment 2 avandecreme 2015-02-04 15:31:52 UTC
I have the same problem if the element is inside of a <td>
Comment 3 Milutin Kristofic 2015-09-03 15:54:20 UTC
I checked code and it is because of this function
org/netbeans/modules/web/indent/api/support/MarkupAbstractIndenter:calculateAllVirtualCloseTagsForOpenTag():697


Netbeans finds unknown tag (messages), virtually close <body> tag and thinks, this is after </body>

I don't know if this functionality is useful. It can be removed, and then it will work well in this case.