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 234794 - Wrong comment tags position in Twig file
Summary: Wrong comment tags position in Twig file
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Twig (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-22 13:13 UTC by mmolda
Modified: 2013-08-22 13:52 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Wrong comment tags position screenshot (20.16 KB, image/png)
2013-08-22 13:13 UTC, mmolda
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mmolda 2013-08-22 13:13:01 UTC
Created attachment 139066 [details]
Wrong comment tags position screenshot

Try to select one or more lines in code.
Make selection start and end in the midde of lines.(look on example)
Press Ctrl+Shift+C to comment.

<!DOCTYPE html>
<html>
    <head></he|ad>  <-- selection starts on '|' position
    <body>
        <div id="content">{% block content %}{% endblock %}</div>
        <div id="footer">
            {% block footer %}
                &copy; Copyright 2011 by <a href="http://domain.invalid/">you</a>.
            {% end|block %}  <-- selection ends on '|' position
        </div>
    </body>
</html>

Result is that comment tags {# and #} are on position where the selection starts and ends. Comment tags should be on the start of the first line and on end of the last line of selection.
Comment 1 mmolda 2013-08-22 13:13:15 UTC
Product Version: NetBeans IDE Dev (Build 201308212300)
Java: 1.7.0_40; Java HotSpot(TM) 64-Bit Server VM 24.0-b55
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b39
System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb)
Comment 2 Ondrej Brejla 2013-08-22 13:26:31 UTC
I don't think so. This is the same behavior as is in Smarty. Where the selection starts and ends there is a comment delimiter.

It makes more sense in such embedded languages (than in Java, ...), because if you have this snippet:

<div>
    <div>Here can be something:^{{if true}}
    {{/endif}}^</div>
</div>

and toggle comment, you really don't want to comment "<div>Here can be something:" as well...

You have better control over commenting. It's not Java or PHP where "line comments" are used. Here we are mixing two contexts, it's a different situation.

For me it's not P3 issue. Maybe P4, or enhancement for discussion. This behavior is intentional.

Changing to enhancement and we will see what will be a user feedback.
Comment 3 mmolda 2013-08-22 13:41:29 UTC
OK, I was comparing it to HTML and PHP behaviour, where the comments are applied for whole lines.

You are right about mixed languages, my example was not the best one, selection should starts and ends on same language (e.g. HTML tags).

In PHP file with HTML I am able to do this:

<di^v>
    <?php echo "abc"; ?>
</d^iv>

and toggle comment, then the result is:

<!--<div>
    <?php echo "abc"; ?>
</div>-->

thanks.
Comment 4 Ondrej Brejla 2013-08-22 13:44:29 UTC
You can do it in Twig (and Smarty) as well, just select "Tools->Options->PHP->Twig->Toggle Comment: language sensitive".

Those are our features ;)
Comment 5 mmolda 2013-08-22 13:49:38 UTC
:) Sorry, I did not realize that.. my bad.
Comment 6 Ondrej Brejla 2013-08-22 13:52:12 UTC
:-) Yes we can rewrite it in PHP too to have such a behavior, but 3 things:

1) This is really really ugly and awful. Noone could read that.

<bo<?php /* ?>dy>
    <div></div>
</bo<?php */ ?>dy>

2) Now almost everyone uses framework and almost every framework uses some templating system which is more powerful and clean, so PHP is used in a separate file and is not mixed with html.

3) People are used to it (same as people using Smarty and other templating langs are used to that "optional" behavior)

But as I said...let it be an enhancement, maybe users will complain, then we can think about it again :)