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 247579 - StringIndexOutOfBoundsException: String index out of range: -1
Summary: StringIndexOutOfBoundsException: String index out of range: -1
Status: VERIFIED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-30 07:14 UTC by Jiri Skrivanek
Modified: 2014-10-06 08:04 UTC (History)
9 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 212326


Attachments
stacktrace (2.10 KB, text/plain)
2014-09-30 07:14 UTC, Jiri Skrivanek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Skrivanek 2014-09-30 07:14:28 UTC
This bug was originally marked as duplicate of bug 229455, that is already resolved. This bug is still valid, so this seems to be another bug, but it might be related.

Build: NetBeans IDE Dev (Build 201409300001)
VM: Java HotSpot(TM) 64-Bit Server VM, 24.65-b04, Java(TM) SE Runtime Environment, 1.7.0_67-b32
OS: Windows 7

User Comments:
GUEST: Moving HTML text arround (<div class="clear"></div>)

Text was moved from inside quotes in a string:
( ' [...] <div class="clear"></div> [...] ' ) 

to outside the quotes temporaraly:
( ' [...] ' + <div class="clear"></div> + '[...]' )

Error was thrown before quotes were added back around it:
( '[...]' + '<div class="clear"></div>' + '[...]')

vriha: I typed > after <script and invoked code completion



<!doctype html>
<html>
    <head>
    </head>
    <body>
        <div>
            <h2>My must-play game list</h2>
        </div>

        <script>
    </body>
</html>

GUEST: just editing...

mkhramov: Typed code in xhtml file:
        <script>
jQuery(document).ready(function(){
	jQuery(".chosen").chosen();
});        
    </head>
Cursor set at eol <script>

jskrivanek: Failed

GUEST: <Please provide a description of the problem or the steps to reproduce>bug

GUEST: theoutput += assignee[2] + "<a href='#' onclick='alert(";

Just moved the cursor to the end of the row.

obrejla: Invoke cc in a Twig file:

<script type="text/javascript"></sc^>

GUEST: Just coding.

GUEST: editing an php file, just pressing the right-arrow a few times.

GUEST: When i close a tag this error occured.

marti1125: When I'm typing javascript code.

danfalos: loading jquery resources on the script tag

GUEST: autocomplete, javascript

GUEST: $.post(
                    "admin.ajax.php" <- error at the end of typing this string (jQuery)
                );

obrejla: CC in Latte file:

<script type="text/javascript"></sc^>

GUEST: typing coded parameters into a JavaScript function call

vriha: Happened in file with single line:

$("document").find('.add-bottom');

I think I did following steps:
- have 
$(document).find('.add-bottom');
- select the "document" and press " (quotes)
- the code changed to 
$("document").find('.add-bottom');
- now I pressed #
=>exception

david.zapata: Autocompleting CTRL + SPACE <script tag in a PHP file with html5 content.

GUEST: Just writing jquery code...

GUEST: selecting text

mrjxn: Ctrl-Space pressed to add </script> tag to PHP webpage (HTML)

GUEST: jquery????????????
jQuery('function)?????
???ctrl+space???????????????

GUEST: nothing special, just coding in javascript.

vriha: What I was doing:
 - KnockoutJSGameList sample project was running on mobile Chrome
 - I opened the only html file in the project and after <script> tag on line 20, I typed <script> to start another script element




Stacktrace: 
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   at java.lang.String.substring(String.java:1911)
   at org.netbeans.modules.javascript2.editor.JsCodeCompletion.getPrefix(JsCodeCompletion.java:376)
   at org.netbeans.modules.csl.editor.completion.GsfCompletionProvider$JavaCompletionQuery.getCompletionEnvironment(GsfCompletionProvider.java:708)
   at org.netbeans.modules.csl.editor.completion.GsfCompletionProvider$JavaCompletionQuery.resolveCompletion(GsfCompletionProvider.java:591)
   at org.netbeans.modules.csl.editor.completion.GsfCompletionProvider$JavaCompletionQuery.access$400(GsfCompletionProvider.java:248)
   at org.netbeans.modules.csl.editor.completion.GsfCompletionProvider$JavaCompletionQuery$1.run(GsfCompletionProvider.java:332)
Comment 1 Jiri Skrivanek 2014-09-30 07:14:35 UTC
Created attachment 149605 [details]
stacktrace
Comment 2 Petr Pisl 2014-09-30 20:09:09 UTC
Should be fixed now in web-main.
Comment 3 Quality Engineering 2014-10-04 04:56:07 UTC
Integrated into 'main-silver', will be available in build *201410040001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/1dc4e35b677d
User: Petr Pisl <ppisl@netbeans.org>
Log: #247579 - StringIndexOutOfBoundsException: String index out of range: -1