Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#729 Next/Previous Word has Problems with Whitespace

3: Ugly
closed-fixed
Lee Marinelli
5
2009-03-13
2009-02-24
Mathias Ricken
No

The changed behavior of next/previous word has problems with whitespace:

If there are consecutive spaces, next/previous word will only advance one space; it should skip the entire block of whitespace.

Discussion

  • Mathias Ricken
    Mathias Ricken
    2009-02-24

    If a line ends in a word (not a separator character), then next word skips to the beginning of the next line. It should stop at the end of the line.

    Example: The | marks the location of the caret.

    // A line with a comment that ends in a |word
    // This is the next line already.

    Pressing next word moves the cursor to:

    // A line with a comment that ends in a word
    |// This is the next line already.

    It should be here:

    // A line with a comment that ends in a word|
    // This is the next line already.

    If there is a separating character at the end, then it works:

    // A line with a comment that ends in a separating character|.
    // This is the next line already.

    Doing next word moves the character to:

    // A line with a comment that ends in a separating character.|
    // This is the next line already.

     
  • Lee Marinelli
    Lee Marinelli
    2009-02-27

    • status: open --> closed-fixed
     
  • Lee Marinelli
    Lee Marinelli
    2009-02-27

    Fixed in the latest stable at http://www.drjava.org/

     
  • Mathias Ricken
    Mathias Ricken
    2009-03-01

    There are problems now that are worse than before the last change to deal with whitespace. If the cursor is moved all the way to the end of a file, it will throw the exception below.

    Consider the cursor movement for the three lines of source code below, starting in line 1 of the editor:

    class DJ0Class {
    int test() {
    System.out.println("DJ0Class.test()");

    The symbol | marks the cursor stops for each "next word" action:

    |class |DJ0Class |{|
    i|nt t|est(|)| |{|
    | Sy|stem.o|u|t.p|r|intln("|D|J|0Class.t|e|st()|"|)|;|
    | |

    Note that the cursor stops in line 1 are all correct. The ones in line 2 are off by one (the last one spilling into the next line), and the ones in line 3 are off by two (the last two spilling into the next line).

    The problem gets worse and worse the further down in the program we get.

    java.lang.IllegalArgumentException: bad position: 345
    at javax.swing.text.JTextComponent.setCaretPosition(JTextComponent.java:1650)
    at edu.rice.cs.drjava.model.definitions.DefinitionsEditorKit$NextWordAction.actionPerformed(DefinitionsEditorKit.java:276)
    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636)
    at edu.rice.cs.drjava.ui.DefinitionsPane.processKeyEvent(DefinitionsPane.java:591)
    at java.awt.Component.processEvent(Component.java:5997)
    at java.awt.Container.processEvent(Container.java:2036)
    at java.awt.Component.dispatchEventImpl(Component.java:4587)
    at java.awt.Container.dispatchEventImpl(Container.java:2094)
    at java.awt.Component.dispatchEvent(Component.java:4417)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668)
    at java.awt.Component.dispatchEventImpl(Component.java:4459)
    at java.awt.Container.dispatchEventImpl(Container.java:2094)
    at java.awt.Window.dispatchEventImpl(Window.java:2475)
    at java.awt.Component.dispatchEvent(Component.java:4417)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

    System Properties:
    DrJava Version drjava-20090301-r4784
    DrJava Build Time 20090301-0235

    drjava.debug.port = 3459
    java.runtime.name = Java(TM) SE Runtime Environment
    sun.boot.library.path = c:\jdk\jre\bin
    java.vm.version = 14.0-b10
    java.vm.vendor = Sun Microsystems Inc.
    java.vendor.url = http://java.sun.com/
    path.separator = ;
    java.vm.name = OpenJDK Client VM
    file.encoding.pkg = sun.io
    sun.java.launcher = SUN_STANDARD
    user.country = US
    sun.os.patch.level = Service Pack 3
    java.vm.specification.name = Java Virtual Machine Specification
    user.dir = <anonymized user.dir>
    java.runtime.version = 1.6.0_14-ea-b01
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
    java.endorsed.dirs = c:\jdk\jre\lib\endorsed
    os.arch = x86
    java.io.tmpdir = c:\DOCUME~1\&lt;anonymized user.name>\LOCALS~1\Temp\ line.separator = "\u000d\u000a"
    java.vm.specification.vendor = Sun Microsystems Inc.
    user.variant =
    os.name = Windows XP
    sun.jnu.encoding = Cp1252
    java.library.path = c:\jdk\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\cygwin\usr\local\bin;c:\jdk\bin;C:\cygwin\packages\apache-ant-1.8.0alpha-r638724-quiet-oneline\bin;C:\cygwin\usr\local\bin;C:\cygwin\bin;C:\cygwin\bin;C:\cygwin\usr\X11R6\bin;c:\jre\bin;c:\jdk\bin;c:\Program Files\Tools\Windows Resource Kits\;c:\WINDOWS\system32;c:\WINDOWS;c:\WINDOWS\System32\Wbem;c:\Program Files\Dev\Perforce;c:\WINDOWS\system32\WindowsPowerShell\v1.0;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Haskell\bin;c:\ghc-6.10.1\bin;c:\Program Files\Internet\SSH Secure Shell;c:\Scala2.7.1\bin;C:\cygwin\usr\sbin
    java.specification.name = Java Platform API Specification
    java.class.version = 50.0
    sun.management.compiler = HotSpot Client Compiler
    os.version = 5.1
    user.home = <anonymized user.home>
    user.timezone = America/Chicago
    java.awt.printerjob = sun.awt.windows.WPrinterJob
    file.encoding = Cp1252
    java.specification.version = 1.6
    java.class.path = <anonymized user.dir>\drjava.jar
    user.name = <anonymized user.name>
    java.vm.specification.version = 1.0
    java.home = c:\jdk\jre
    sun.arch.data.model = 32
    user.language = en
    java.specification.vendor = Sun Microsystems Inc.
    awt.toolkit = sun.awt.windows.WToolkit
    java.vm.info = mixed mode
    java.version = 1.6.0_14-ea
    java.ext.dirs = c:\jdk\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
    sun.boot.class.path = c:\jdk\jre\lib\resources.jar;c:\jdk\jre\lib\rt.jar;c:\jdk\jre\lib\sunrsasign.jar;c:\jdk\jre\lib\jsse.jar;c:\jdk\jre\lib\jce.jar;c:\jdk\jre\lib\charsets.jar;c:\jdk\jre\classes
    java.vendor = Sun Microsystems Inc.
    file.separator = \ java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
    sun.io.unicode.encoding = UnicodeLittle
    sun.cpu.endian = little
    java.rmi.server.hostname = 127.0.0.1
    sun.desktop = windows
    sun.cpu.isalist = pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

    #DrJava configuration file
    #Sat Feb 28 21:24:05 CST 2009
    interactions.auto.import.class.string = java.io.*
    lineenum.enabled = true
    key.delete.next = shift DELETE
    key.delete.previous = shift BACK_SPACE
    find.replace.match.case = false
    find.replace.all.documents = true
    quit.prompt = false
    open.folder.recursive = true
    language.level = 3
    recent.files = [<anonymized user.home>\\Documents\\Dev\\Java\\DJ2Class.dj2,<anonymized user.home>\\Documents\\Dev\\Java\\DJ1Class.dj1,<anonymized user.home>\\Documents\\Dev\\Java\\DJ0Class.dj0,R:\\Concutest\\ClassLoader\\src\\AnnotationTest.java,R:\\Concutest\\ClassLoader\\src\\ClassLockTest.java]
    recent.projects = [<anonymized user.home>\\Documents\\drjava\\drjava.xml,R:\\Concutest\\ClassLoader\\ClassLoader.xml,<anonymized user.home>\\Documents\\Web\\&lt;anonymized user.name>.cs\\teaching\\202\\08-fall\\staff\\exams\\2\\2008\\solution\\graph\\graph.xml,<anonymized user.home>\\Documents\\Semester 10 Spring 2009\\COMP 402\\bb.student\\BoundedBuffer.xml]
    window.height = 1555
    window.width = 1208
    window.x = -4
    window.y = -4
    window.state = 6
    doc.list.width = 261
    last.dir = <anonymized user.home>\\Documents\\Dev\\Java\\DJ0Class.dj0
    last.interactions.dir = <anonymized user.home>\\Documents\\Dev\\Java
    master.jvm.xmx = 1024
    dialog.clipboard.history.state = 402 400 399 573
    dialog.completeword.javaapi = true
    tabbedpanes.state = 1199 -3 1154 514
    tabbedpanes.detach = true
    debugger.state = 1200 504 1151 421
    debugger.detach = true
    find.replace.focus.in.defpane = true
    new.version.notification.last = 1235444591078
    drjava.survey.notification.last = 1235790765328
    drjava.survey.result.last = http://www.drjava.org/submit-usage.php?rev=4784&os.name=Windows%20XP&os.version=5.1&java.version=1.6.0_14-ea&java.vendor=Sun%20Microsystems%20Inc.

    Used memory: about 7.51 megabytes
    Free memory: about 3.43 megabytes
    Total memory: about 10.95 megabytes
    Total memory can expand to: about 1016.12 megabytes

     
  • Mathias Ricken
    Mathias Ricken
    2009-03-01

    • assigned_to: nobody --> llm1
    • milestone: 173642 --> 3: Ugly
    • status: closed-fixed --> open
     
  • Mathias Ricken
    Mathias Ricken
    2009-03-01

    The easiest way to reproduce the exception below is to go to the end of a document and press "next word".

     
  • Mathias Ricken
    Mathias Ricken
    2009-03-02

    This appears to be a Windows-only bug.

     
  • Mathias Ricken
    Mathias Ricken
    2009-03-02

    Here's another exception generated by clicking on the first word in a file:

    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.charAt(Unknown Source)
    at edu.rice.cs.drjava.model.definitions.DefinitionsEditorKit$BeginWordAction.actionPerformed(DefinitionsEditorKit.java:145)
    at edu.rice.cs.drjava.model.definitions.DefinitionsEditorKit$SelectWordAction.actionPerformed(DefinitionsEditorKit.java:294)
    at javax.swing.text.DefaultCaret.selectWord(Unknown Source)
    at javax.swing.text.DefaultCaret.mousePressed(Unknown Source)
    at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
    at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    System Properties:
    DrJava Version drjava-20090302-r4787
    DrJava Build Time 20090302-1540

    drjava.debug.port = 1127
    java.runtime.name = Java(TM) SE Runtime Environment
    sun.boot.library.path = C:\Program Files\Java\jre1.6.0_07\bin
    java.vm.version = 10.0-b23
    java.vm.vendor = Sun Microsystems Inc.
    java.vendor.url = http://java.sun.com/
    path.separator = ;
    java.vm.name = Java HotSpot(TM) Client VM
    file.encoding.pkg = sun.io
    sun.java.launcher = SUN_STANDARD
    user.country = US
    sun.os.patch.level = Service Pack 3
    java.vm.specification.name = Java Virtual Machine Specification
    user.dir = <anonymized user.home>\Desktop
    java.runtime.version = 1.6.0_07-b06
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
    java.endorsed.dirs = C:\Program Files\Java\jre1.6.0_07\lib\endorsed
    os.arch = x86
    java.io.tmpdir = C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ line.separator = "\u000d\u000a"
    java.vm.specification.vendor = Sun Microsystems Inc.
    user.variant =
    os.name = Windows XP
    sun.jnu.encoding = Cp1252
    java.library.path = C:\Program Files\Java\jre1.6.0_07\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\jre\bin;C:\jdk\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Tools;C:\cygwin\packages\apache-ant-1.7.1\bin;C:\cygwin\bin
    java.specification.name = Java Platform API Specification
    java.class.version = 50.0
    sun.management.compiler = HotSpot Client Compiler
    os.version = 5.1
    user.home = <anonymized user.home>
    user.timezone = Europe/Berlin
    java.awt.printerjob = sun.awt.windows.WPrinterJob
    file.encoding = Cp1252
    java.specification.version = 1.6
    java.class.path = <anonymized user.home>\Desktop\drjava.jar
    user.name = <anonymized user.name>
    java.vm.specification.version = 1.0
    java.home = C:\Program Files\Java\jre1.6.0_07
    sun.arch.data.model = 32
    user.language = en
    java.specification.vendor = Sun Microsystems Inc.
    awt.toolkit = sun.awt.windows.WToolkit
    java.vm.info = mixed mode, sharing
    java.version = 1.6.0_07
    java.ext.dirs = C:\Program Files\Java\jre1.6.0_07\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
    sun.boot.class.path = C:\Program Files\Java\jre1.6.0_07\lib\resources.jar;C:\Program Files\Java\jre1.6.0_07\lib\rt.jar;C:\Program Files\Java\jre1.6.0_07\lib\sunrsasign.jar;C:\Program Files\Java\jre1.6.0_07\lib\jsse.jar;C:\Program Files\Java\jre1.6.0_07\lib\jce.jar;C:\Program Files\Java\jre1.6.0_07\lib\charsets.jar;C:\Program Files\Java\jre1.6.0_07\classes
    java.vendor = Sun Microsystems Inc.
    file.separator = \ java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
    sun.io.unicode.encoding = UnicodeLittle
    sun.cpu.endian = little
    java.rmi.server.hostname = 127.0.0.1
    sun.desktop = windows
    sun.cpu.isalist = pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

    #DrJava configuration file
    #Mon Mar 02 16:50:53 CET 2009
    javac.location = C:\\jdk\\lib\\tools.jar
    key.delete.next = shift DELETE
    key.delete.previous = shift BACK_SPACE
    find.replace.match.case = false
    find.replace.all.documents = true
    open.folder.recursive = true
    window.height = 580
    window.width = 808
    window.x = 0
    window.y = 0
    last.dir = C:\\Documents and Settings\\&lt;anonymized user.name>\\Desktop
    last.interactions.dir = C:\\Documents and Settings\\&lt;anonymized user.name>\\My Documents
    tabbedpanes.state = 640 339 700 400
    new.version.notification.last = 1236008823209
    drjava.survey.notification.last = 1234822260297
    drjava.survey.result.last = http://www.drjava.org/submit-usage.php?rev=4760&os.name=Windows%20XP&os.version=5.1&java.version=1.6.0_07&java.vendor=Sun%20Microsystems%20Inc.

    Used memory: about 6.92 megabytes
    Free memory: about 4.05 megabytes
    Total memory: about 10.97 megabytes
    Total memory can expand to: about 63.56 megabytes

     
  • Mathias Ricken
    Mathias Ricken
    2009-03-02

    • status: open --> closed-fixed
     
  • Mathias Ricken
    Mathias Ricken
    2009-03-02

    Fixed as of revision 4789.

    The main problem was that JTextComponent.getText() translates newlines to System.getProperty("line.separator"), which is two characters long on Windows. The internal offset, however, is just based on "\n" newlines. Therefore, the offset always got one character too large per line. Instead, we are now using JTextComponent.getDocument().getText(...), which keeps the internal representation.

    Also fixed two problems with boundary conditions.

     
  • Mathias Ricken
    Mathias Ricken
    2009-03-09

    "Next/Previous Word" now works as expected, but "Select Next/Previous Word" (the same, but with Shift pressed to select the word) still seems to exhibit the old behavior.

     
  • Mathias Ricken
    Mathias Ricken
    2009-03-09

    • status: closed-fixed --> open-fixed
     
  • Mathias Ricken
    Mathias Ricken
    2009-03-13

    Fixed as of revision 4811.

     
  • Mathias Ricken
    Mathias Ricken
    2009-03-13

    • status: open-fixed --> closed-fixed