#1620 Possible WordStartPosition / WordEndPosition bug

Bug
closed-invalid
Neil Hodgson
scintilla (140)
2
2014-08-15
2014-07-07
klo
No

Consider this Lua function:

print(editor.CurrentPos..':'..editor:WordEndPosition(editor.CurrentPos))

If cursor is at the word end (current position is same as end position) then editor:WordEndPosition reports position larger by 1. If cursor is inside word, then reported word end position is correct.

The same faulty rule can be observed for editor:WordStartPosition, too.

Discussion

  • klo
    klo
    2014-07-07

    It looks like something is forbidding editor.CurrentPos to be same with either or reported positioning functions.

     
  • Neil Hodgson
    Neil Hodgson
    2014-07-07

    This function looks at the character after the position, then searches forward for the next change in character class. They never look at the previous character. Its exposing the code Scintilla uses for the Ctrl+Right key.

     
  • klo
    klo
    2014-07-07

    Can not see the logic...

    For example, I have document with content:

    Hello World
    

    If I place the cursor inside each word I get 0:5 and 6:11 respectively for WordStartPosition and WordEndPosition.
    If I place the cursor after letter "o" in Hello, it's CurrentPos is 5 as expected, while WordEndPosition is reported 6 which is WordStartPosition of the next word.

    Also if place the cursor after letter "d" in World, and if there is no space after it, I get 6:11, but if I add single space I get 6:12.

    If this is how it is supposed to work then Ok.
    Maybe just it does not make sense to my expectations.

     
    • Neil Hodgson
      Neil Hodgson
      2014-07-07

      That is how it is supposed to work, just like the Ctrl+Right key.

       
  • Neil Hodgson
    Neil Hodgson
    2014-07-07

    • labels: --> scintilla
    • status: open --> open-invalid
    • assigned_to: Neil Hodgson
    • Priority: 5 --> 2
     
  • Neil Hodgson
    Neil Hodgson
    2014-08-14

    • status: open-invalid --> closed-invalid