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 223853 - IllegalArgumentException: bad position: 11
Summary: IllegalArgumentException: bad position: 11
Status: NEW
Alias: None
Product: third-party
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 7.3
Hardware: All Mac OS X
: P3 normal (vote)
Assignee: err
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-14 17:26 UTC by tomjnsn
Modified: 2013-09-16 00:09 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 191546


Attachments
stacktrace (6.12 KB, text/plain)
2012-12-14 17:26 UTC, tomjnsn
Details
Should not be highlighting end of line. (181.21 KB, image/png)
2013-09-09 06:38 UTC, digitalrounin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tomjnsn 2012-12-14 17:26:52 UTC
Build: NetBeans IDE Dev (Build 201212140001)
VM: Java HotSpot(TM) 64-Bit Server VM, 23.3-b01, Java(TM) SE Runtime Environment, 1.7.0_07-b10
OS: Mac OS X

Stacktrace: 
java.lang.IllegalArgumentException: bad position: 11
   at javax.swing.text.JTextComponent.moveCaretPosition(JTextComponent.java:1551)
   at com.raelity.jvi.swing.CommandLine$CommandLineEntry$2.focusGained(CommandLine.java:594)
   at java.awt.AWTEventMulticaster.focusGained(AWTEventMulticaster.java:220)
   at java.awt.Component.processFocusEvent(Component.java:6394)
   at java.awt.Component.processEvent(Component.java:6261)
   at java.awt.Container.processEvent(Container.java:2229)
Comment 1 tomjnsn 2012-12-14 17:26:56 UTC
Created attachment 129388 [details]
stacktrace
Comment 2 Ondrej Vrabec 2012-12-17 13:46:41 UTC
com.raelity.jvi...
Comment 3 err 2012-12-17 16:16:34 UTC
tomjnsn,

Is this repeatable? Frequent/infrequent? Did it start with a recent NB-dev build? What jVi version?

What is the jVi option setting for Tools>Options>jViConfig>Platform>useModalFrame?
Comment 4 err 2013-09-08 17:38:42 UTC
digitalrounin,

There have been three of these exceptions reported over the last year; always on a MAC running 1.7 JVM. The latest is yesterday. The exception occurs in some code that executes only on a MAC and was added in April of 2008. The code adds a focus gained listener to the text field in the commandLine combo box to adjust the text selection to work around some issue.

I'm assuming that this occurs infrequently. It is only reported on JVM 1.7.

The latest report, from digitalrounin, has a comment (thanks). It says
     Just performed ':s/\s\+$//g' in JVi 
The command that shows up in the combo box editor is 10 chars (don't count the ':'). So '11' for the position is bad (assuming it was working with the whole string).

Could you clarify the "Just performed". Does this mean the exception occurred after pressing RETURN? Or maybe after running it and then entering ':' again? Can you recall if there might have been any type ahead (that is almost impossible to be sure of)?

I could just have the code ignore the exception. This probably leaves the selection funny; but it is pretty infrequent.
Comment 5 digitalrounin 2013-09-09 06:36:15 UTC
Hey err,
I cannot recall.  I apologize.  I will try and keep such things in mind when I file bugs in the future.

Here is something interesting though.  I tried to  to recreate the issue and the funny thing is that my substitute command is not working at all.

Recreation steps:
  1. Put trailing spaces at random lines through out the file being edited.  Please space chars. ' '
  2. Enter ex with ':'
  3. Enter the following at ':', %s/\s\+$//g

Result:
  1. About 0.5 to 1 second delay, long time IMHO
  2. Bell/alert rings once
  3. 'hlsearch' highlights end of line for all lines
  4. Trailing spaces have not beed removed.

Number 3 of the result is also a little unexpected.  I am going to try and attach a screen shot after I post this.

Either way, I know that the trailing 'g' in '%s/\s\+$//g' is not needed, but it is still a valid command.  I tested the command out on the same exact file in plain old Vim and it works.
Comment 6 digitalrounin 2013-09-09 06:38:38 UTC
Created attachment 139817 [details]
Should not be highlighting end of line.

I am not sure if this is a separate bug or related.

FYI.  Nothing in the Netbeans logs.
Comment 7 err 2013-09-09 13:39:53 UTC
> I tested the command out on the same exact file in plain old Vim and it works.

There is a discrepancy in the meaning of '\s' between vim and java. Java uses perl meaning and '\s' includes '\n' (and a few other things), but vim only include space and tab. I might consider simple substituting '[ \t]' for '\s' but I'm concerned this might fail in more complex examples, for example using negation. Issues related to this should be filed at jVi's sourceforge site.

Instead of '%s/\s\+$//g', using '%s/[ \t]\+$//g' should give you the expected results. I'll see what I can recreate later today. Using a reluctant quantifier, as in '/\s+?$/' might work (but you may need to escape '+' and '?' depending on options)
Comment 8 err 2013-09-16 00:09:00 UTC
For the upcoming bug fix release, the exception message contains additional information to get a better idea of what's going on.

I've left the exception, rather than just outputting stuff, since it doesn't seem to cause any real problems.