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 226828

Summary: Embedded JS code in HTML file creates wrong highlight
Product: javascript Reporter: meanyack
Component: EditorAssignee: Petr Pisl <ppisl>
Status: VERIFIED FIXED    
Severity: normal CC: aneyeforanapi, ecerichter, mmirilovic, nb_johan1, po_taka, vriha
Priority: P2    
Version: 7.3   
Hardware: PC   
OS: Other   
Issue Type: DEFECT Exception Reporter:
Attachments: cursor is on a variable, but it highlights wrong places.
sample file
javax.swing.text.BadLocationException

Description meanyack 2013-02-28 10:41:40 UTC
Created attachment 132004 [details]
cursor is on a variable, but it highlights wrong places.

Create a html file and write some javascript inside it. When you move the cursor, sometimes it highlights irrelevant areas in the document. If you press Ctrl + R, it selects all the texts and changes whole area.
Comment 1 Vladimir Riha 2013-03-01 13:43:33 UTC
Created attachment 132067 [details]
sample file

Reproducible, in the attached sample file, focus "wine" on line 16. However try "addWine", "AppRouter" etc. and it works fine. What seems to caused it is usage of the variable in object literal (line 17 in this case)
Comment 2 Vladimir Riha 2013-03-08 06:45:24 UTC
*** Bug 227158 has been marked as a duplicate of this bug. ***
Comment 3 Vladimir Riha 2013-03-15 22:40:06 UTC
*** Bug 227451 has been marked as a duplicate of this bug. ***
Comment 4 meanyack 2013-03-17 20:57:48 UTC
I'm pretty sure this wasn't an issue in previous versions (ie 6.9) I heard that javascript parser changed in the new versions maybe that causes this problem ?

New parser is known as Nashor while the old one was Rhino. Link: 

http://netbeans.org/bugzilla/show_bug.cgi?id=226477#c1
Comment 5 Petr Pisl 2013-03-18 13:37:48 UTC
@meanyack: You are right. NetBeans 7.3 has basically new JS Editor that is based on new parser from Nashorn project. IMHO Nashorn is not the causion of this issue.
Comment 6 Petr Pisl 2013-03-18 14:35:42 UTC
Thanks for the example. I can reproduce it as well.
Comment 7 meanyack 2013-03-25 09:37:27 UTC
Created attachment 133021 [details]
javax.swing.text.BadLocationException

javax.swing.text.BadLocationException
Comment 8 meanyack 2013-03-25 09:39:38 UTC
Comment on attachment 133021 [details]
javax.swing.text.BadLocationException

<record>
  <date>2013-03-25T11:34:50</date>
  <millis>1364204090614</millis>
  <sequence>5332</sequence>
  <level>SEVERE</level>
  <thread>20</thread>
  <message>Invalid offset=1112 &gt; (docLen+1)=883</message>
  <exception>
    <message>javax.swing.text.BadLocationException: Invalid offset=1112 &gt; (docLen+1)=883</message>
    <frame>
      <class>org.netbeans.modules.editor.lib2.document.EditorDocumentContent</class>
      <method>checkOffsetInContent</method>
      <line>280</line>
      <file>${netBeansDir}modules/org-netbeans-modules-editor-lib2.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.modules.editor.lib2.document.EditorDocumentContent</class>
      <method>createPosition</method>
      <line>192</line>
      <file>${netBeansDir}modules/org-netbeans-modules-editor-lib2.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.editor.BaseDocument</class>
      <method>createPosition</method>
      <line>1357</line>
      <file>${netBeansDir}modules/org-netbeans-modules-editor-lib.jar</file>
    </frame>
    <frame>
      <class>org.openide.text.NbDocument</class>
      <method>createPosition</method>
      <line>225</line>
      <file>${netbeans.home}modules/org-openide-text.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.modules.csl.editor.InstantRenamePerformer</class>
      <method>&lt;init&gt;</method>
      <line>114</line>
      <file>${netBeansDir}modules/org-netbeans-modules-csl-api.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.modules.csl.editor.InstantRenamePerformer</class>
      <method>performInstantRename</method>
      <line>172</line>
      <file>${netBeansDir}modules/org-netbeans-modules-csl-api.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.modules.csl.api.InstantRenameAction</class>
      <method>doInstantRename</method>
      <line>250</line>
      <file>${netBeansDir}modules/org-netbeans-modules-csl-api.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.modules.csl.api.InstantRenameAction</class>
      <method>access$000</method>
      <line>99</line>
      <file>${netBeansDir}modules/org-netbeans-modules-csl-api.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.modules.csl.api.InstantRenameAction$3</class>
      <method>run</method>
      <line>214</line>
      <file>${netBeansDir}modules/org-netbeans-modules-csl-api.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.editor.BaseDocument</class>
      <method>render</method>
      <line>1383</line>
      <file>${netBeansDir}modules/org-netbeans-modules-editor-lib.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.modules.csl.api.InstantRenameAction</class>
      <method>actionPerformed</method>
      <line>209</line>
      <file>${netBeansDir}modules/org-netbeans-modules-csl-api.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.editor.BaseAction</class>
      <method>actionPerformed</method>
      <line>339</line>
      <file>${netBeansDir}modules/org-netbeans-modules-editor-lib.jar</file>
    </frame>
    <frame>
      <class>javax.swing.SwingUtilities</class>
      <method>notifyAction</method>
      <line>1664</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>javax.swing.JComponent</class>
      <method>processKeyBinding</method>
      <line>2879</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>javax.swing.JComponent</class>
      <method>processKeyBindings</method>
      <line>2926</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>javax.swing.JComponent</class>
      <method>processKeyEvent</method>
      <line>2842</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Component</class>
      <method>processEvent</method>
      <line>6282</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Container</class>
      <method>processEvent</method>
      <line>2229</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Component</class>
      <method>dispatchEventImpl</method>
      <line>4861</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Container</class>
      <method>dispatchEventImpl</method>
      <line>2287</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Component</class>
      <method>dispatchEvent</method>
      <line>4687</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.KeyboardFocusManager</class>
      <method>redispatchEvent</method>
      <line>1895</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.DefaultKeyboardFocusManager</class>
      <method>dispatchKeyEvent</method>
      <line>762</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.DefaultKeyboardFocusManager</class>
      <method>preDispatchKeyEvent</method>
      <line>1027</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.DefaultKeyboardFocusManager</class>
      <method>typeAheadAssertions</method>
      <line>899</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.DefaultKeyboardFocusManager</class>
      <method>dispatchEvent</method>
      <line>727</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Component</class>
      <method>dispatchEventImpl</method>
      <line>4731</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Container</class>
      <method>dispatchEventImpl</method>
      <line>2287</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Window</class>
      <method>dispatchEventImpl</method>
      <line>2719</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.Component</class>
      <method>dispatchEvent</method>
      <line>4687</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventQueue</class>
      <method>dispatchEventImpl</method>
      <line>729</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventQueue</class>
      <method>access$200</method>
      <line>103</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventQueue$3</class>
      <method>run</method>
      <line>688</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventQueue$3</class>
      <method>run</method>
      <line>686</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.security.AccessController</class>
      <method>doPrivileged</method>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.security.ProtectionDomain$1</class>
      <method>doIntersectionPrivilege</method>
      <line>76</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.security.ProtectionDomain$1</class>
      <method>doIntersectionPrivilege</method>
      <line>87</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventQueue$4</class>
      <method>run</method>
      <line>702</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventQueue$4</class>
      <method>run</method>
      <line>700</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.security.AccessController</class>
      <method>doPrivileged</method>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.security.ProtectionDomain$1</class>
      <method>doIntersectionPrivilege</method>
      <line>76</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventQueue</class>
      <method>dispatchEvent</method>
      <line>699</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>org.netbeans.core.TimableEventQueue</class>
      <method>dispatchEvent</method>
      <line>159</line>
      <file>${netbeans.home}modules/org-netbeans-core.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventDispatchThread</class>
      <method>pumpOneEventForFilters</method>
      <line>242</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventDispatchThread</class>
      <method>pumpEventsForFilter</method>
      <line>161</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventDispatchThread</class>
      <method>pumpEventsForHierarchy</method>
      <line>150</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventDispatchThread</class>
      <method>pumpEvents</method>
      <line>146</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventDispatchThread</class>
      <method>pumpEvents</method>
      <line>138</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
    <frame>
      <class>java.awt.EventDispatchThread</class>
      <method>run</method>
      <line>91</line>
      <file>${java.home}lib/rt.jar</file>
    </frame>
  </exception>
</record>

<record>
  <date>2013-03-25T11:34:59</date>
  <millis>1364204099758</millis>
  <sequence>6895</sequence>
  <level>CONFIG</level>
  <thread>139</thread>
  <message>UI_USER_CONFIGURATION</message>
  <key>UI_USER_CONFIGURATION</key>
  <catalog>org.netbeans.modules.uihandler.Bundle</catalog>
  <param>Windows 8, 6.2, amd64</param>
  <param>Java HotSpot(TM) 64-Bit Server VM, 23.7-b01, Java(TM) SE Runtime Environment, 1.7.0_13-b20</param>
  <param>NetBeans IDE 7.3 (Build 201302132200)</param>
  <param></param>
  <param>javax.swing.text.BadLocationException: Invalid offset=1112 &gt; (docLen+1)=883</param>
  <param></param>
  <param>*********</param>
</record>
Comment 9 meanyack 2013-03-25 09:46:07 UTC
Is there any progress about this issue? I think variable highlighting is one of the most useful property in NB. Using Alt+Up and Alt+Down saves minutes (and maybe hours). Now I really suffer because most of time I see yellow background color of hundred of lines which disturbs me much.

I don't know it helps but if you copy/paste sample file in NB, place cursor on 'wine' keyword and press Ctrl+R (rename keyword), it throws and exception. You can find log here: http://statistics.netbeans.org/analytics/exception.do?id=666771
Comment 10 meanyack 2013-03-25 10:24:50 UTC
I'm sorry about the comments above. I was trying to edit/remove attachment I posted.
Comment 11 Petr Pisl 2013-03-25 13:09:42 UTC
So the highlighting is fixed. The attached example works fine and the cases from duplicates as well. 

http://hg.netbeans.org/web-main/rev/3eb099eeedbb
Comment 12 Petr Pisl 2013-03-25 13:54:42 UTC
*** Bug 227740 has been marked as a duplicate of this bug. ***
Comment 13 Quality Engineering 2013-03-26 01:58:43 UTC
Integrated into 'main-golden', will be available in build *201303252300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/3eb099eeedbb
User: Petr Pisl <ppisl@netbeans.org>
Log: #226828 - Embedded JS code in HTML file creates wrong highlight
Comment 14 Vladimir Riha 2013-03-26 07:13:22 UTC
Thanks, verified

Product Version: NetBeans IDE Dev (Build web-main-10169-on-20130326)
Java: 1.7.0_17; Java HotSpot(TM) Client VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_17-b32
System: Linux version 3.2.0-39-generic-pae running on i386; UTF-8; en_US (nb)
Comment 15 Petr Pisl 2013-05-06 12:01:34 UTC
Backported to release73 as c9968c0023c3
Comment 16 Quality Engineering 2013-05-07 00:18:50 UTC
Integrated into 'releases', will be available in build *201305062200* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/c9968c0023c3
User: Petr Pisl <ppisl@netbeans.org>
Log: #226828 - transplanting fix
Comment 17 Vladimir Riha 2013-05-09 13:46:34 UTC
Product Version: NetBeans IDE 7.3.1 (Build 201302132200)
Java: 1.7.0_21; Java HotSpot(TM) Client VM 23.21-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b11
System: Linux version 3.2.0-41-generic-pae running on i386; UTF-8; en_US (nb)