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 268440

Summary: Autoformater destroys Sourcecode
Product: web Reporter: mokraemer
Component: HTML EditorAssignee: Petr Pisl <ppisl>
Status: REOPENED ---    
Severity: normal CC: tmysik
Priority: P1    
Version: 8.2   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: Formting settings in nb
File with false formating
Error

Description mokraemer 2016-10-10 09:57:06 UTC
Mixed content (php+html+js) seems to puzzle the autoformater.
I have no clue where or when this happens but on some sources html-tags and js-functions get destroyed to e.g.

						<							button type="button" onclick="scale(7);" title="Week">7</button>
						<but							ton type="button" onclick="scale(30);" title="month">30</button>
<button							type="button"  onclick="zoom(-0.2);" title="more"><i class="fa fa-lg fa-search-plus"></i></button>

or
top.timeline = new vis.Timeline(container, new vis.DataSet([<?= implode(',', getCalendarEntries()); ?>]), new vis.DataSet([<?= implode(',', $fz); ?>]), timelineOption							s);


You can see the added Spaces/Tabs inside tags or function calls which destroys the sourcecode!
Comment 1 Tomas Mysik 2016-10-10 10:22:58 UTC
Would be great if you could attach a sample file.

Reassigning to HTML, please evaluate. Thanks.
Comment 2 mokraemer 2016-10-10 11:16:07 UTC
Created attachment 162427 [details]
Formting settings in nb

maybe this is relevant?
Comment 3 mokraemer 2016-10-10 11:17:05 UTC
Created attachment 162428 [details]
File with false formating

just a demo, much source code was removed to get some kind of minimal example
Comment 4 mokraemer 2016-10-10 11:21:26 UTC
I've added an (reduced) example attached where autoformater destroys the source code.
If you format the source once you get at least a line
<button type="button" onclick="scale(1);" title="Tagesansicht">1</but						ton>

Maybe there are other faulty formats
if you do this again you get these lines:
								<bu						tton type="button" onclick="scale(30);" title="Monatansicht">30</button>
								<but						ton type="button"  onclick="zoom(-0.2);" title="mehr Details"><i class="fa fa-lg fa-search-plus"></i></button>

and 
				</s									crip						t>
				<div id="newEntry" style="di										splay:none							">
					<fo											rm name="newEntry								">
						<table class="editTable sta													ndard">


and some more....
(if relevant, I found many places where nb 8.2 does indentations and formating very different even in full php-source, e.g. missing indentation on ternary operators)
Comment 5 mokraemer 2016-10-18 17:07:21 UTC
do you have anything new about this?
The main problem is, the changes are applied and you don't see that the code is broken. You get this only by testing. But if you change a comment, do a reformat on save or manual, you don't expect the code to be broken and won't test it.
Comment 6 mokraemer 2016-11-08 11:45:00 UTC
since this is a severe bug, changed priority to data-loss, since formating causes data-loss.
Comment 7 Milutin Kristofic 2016-12-05 15:44:22 UTC
Shouldn't this be indented by smarty template? I am sending this for investigation.
Comment 8 Tomas Mysik 2017-03-24 15:08:00 UTC
The file is manage.tmpl - what is *.tmpl? What MIME type do you use? PHP? Smarty? Any other one?

Simply reopen this issue, thanks.
Comment 9 mokraemer 2017-03-24 15:25:39 UTC
tmpl stands for "template" can be a mixture of html/js/php code. Every code segment is opened by the specific html-tags.

But no matter what the file format is or what it is recognized, tags should never break.
Comment 10 Tomas Mysik 2017-03-27 06:06:55 UTC
(In reply to Tomas Mysik from comment #8)
> What MIME type do you use? PHP? Smarty? Any other one?

Again, I need to know the MIME type you have set for this file extension. Thanks.
Comment 11 mokraemer 2017-03-27 13:28:13 UTC
I never set any mime type to this file extension.
If you mean the uderlying os, it reports:
$ file test.tmpl 
test.tmpl: PHP script, UTF-8 Unicode text, with very long lines, with CRLF line terminators

So I expect nb to handle the source as php
Comment 12 Tomas Mysik 2017-03-27 13:40:49 UTC
So, I opened the file you have attached, verified that it has PHP MIME type and tried to format it. I got an error, see my attachment. So reassigning to HTML, please evaluate.

Thanks.

Product Version: NetBeans IDE Dev (Build 20170327-41b3145bc1cc)
Java: 1.8.0_121; Java HotSpot(TM) 64-Bit Server VM 25.121-b13
Runtime: Java(TM) SE Runtime Environment 1.8.0_121-b13
System: Linux version 4.8.0-42-generic running on amd64; UTF-8; cs_CZ (nb)
Comment 13 Tomas Mysik 2017-03-27 13:41:21 UTC
Created attachment 163956 [details]
Error