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 268621 - code indentation broken when I push down the opening curly bracket of a method
Summary: code indentation broken when I push down the opening curly bracket of a method
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.2
Hardware: All All
: P3 normal (vote)
Assignee: junichi11
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-20 23:10 UTC by par7133
Modified: 2016-11-09 09:02 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (49.65 KB, text/plain)
2016-10-20 23:11 UTC, par7133
Details
after (18.54 KB, image/png)
2016-10-20 23:11 UTC, par7133
Details
before (17.24 KB, image/png)
2016-10-20 23:12 UTC, par7133
Details

Note You need to log in before you can comment on or make changes to this bug.
Description par7133 2016-10-20 23:10:58 UTC
Product Version = NetBeans IDE 8.2 (Build 201609300101)
Operating System = Linux version 4.7.5-200.fc24.x86_64 running on amd64
Java; VM; Vendor = 1.8.0_101
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.101-b13

Reproducibility: Happens every time

Reproducibility: Happens every time

STEPS:
  * I have the following indentation settings for all the languages:
      Expand Tabs to Spaces: yes
      Number of Spaces per indent: 2
      Tab Size: 2
    inherited by all the languages (PHP and Javascript included)
  * I'm in a PHP class writing some code (please consider also the number of spaces included):
  public static function HTMLencode($s) {
    return htmlentities($s, ENT_QUOTES |ENT_IGNORE | ENT_HTML5, "UTF-8");
  } 
  * The code doesn't complain with a PHP coding standards because the opening curly bracket position.
    So, I position the cursor just before the opening curly bracket and I push it down a line.
 * The result is unexpected: 
  public static function HTMLencode($s) 
          {
    return htmlentities($s, ENT_QUOTES |ENT_IGNORE | ENT_HTML5, "UTF-8");
  }  
  * the indentation of the curly bracket get broken instead to align correctly under the visibility keyword. 

ACTUAL:
  the indentation of the existing code get broken

EXPECTED:
  the indentation of the code should be adequate correctly
Comment 1 par7133 2016-10-20 23:11:05 UTC
Created attachment 162578 [details]
IDE log
Comment 2 par7133 2016-10-20 23:11:58 UTC
Created attachment 162579 [details]
after
Comment 3 par7133 2016-10-20 23:12:00 UTC
Created attachment 162580 [details]
before
Comment 4 Tomas Mysik 2016-10-24 05:23:41 UTC
Thanks for reporting.
Comment 5 junichi11 2016-11-08 02:12:02 UTC
Fixed.

http://hg.netbeans.org/web-main/rev/3d716a8ca6a2

Tomas, PHPFormatter.reindent was invoked twice(It means that an indentation may be broken. Actually, my fix was broken). So, I also checked Context.mimePath(). One MimePath of Context has text/javascript as a mimeType when I debug it. 

Thanks!
Comment 6 Tomas Mysik 2016-11-08 09:25:46 UTC
(In reply to junichi11 from comment #5)
> Tomas, PHPFormatter.reindent was invoked twice(It means that an indentation
> may be broken. Actually, my fix was broken). So, I also checked
> Context.mimePath(). One MimePath of Context has text/javascript as a
> mimeType when I debug it.

So, should we report a bug against JavaScript? Or..?

Anyway, thanks for the fix, Junichi!
Comment 7 junichi11 2016-11-08 10:01:14 UTC
(In reply to Tomas Mysik from comment #6)
> So, should we report a bug against JavaScript? Or..?

Probably, I think that it's no problem because we can avoid that. I just wanted to let you know the reason for my change :)

Just information: It seems that Html and CSS use the specific class(CssIndentTask, HtmlIndentTask). Other than that(JS, PHP) use GsfIndentTask.
 
> Anyway, thanks for the fix, Junichi!

You are welcome :)
Comment 8 Tomas Mysik 2016-11-08 10:48:11 UTC
(In reply to junichi11 from comment #7)
> Probably, I think that it's no problem because we can avoid that. I just
> wanted to let you know the reason for my change :)

So, if you have a reproducible use case, feel free to report it, please.

Thanks!
Comment 9 junichi11 2016-11-08 11:00:38 UTC
(In reply to Tomas Mysik from comment #8)
> So, if you have a reproducible use case, feel free to report it, please.

I see. Thanks!
Comment 10 Quality Engineering 2016-11-09 09:02:43 UTC
Integrated into 'main-silver', will be available in build *201611090620* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/3d716a8ca6a2
User: Junichi Yamamoto <junichi11@netbeans.org>
Log: #268621 - code indentation broken when I push down the opening curly bracket of a method