Ticket #124: libwidg_fix_1_of_1_rev_c4547d964655_EditTextView__Fixed_long_standing_bug_with_inconsistent_cursor_position_after_select_word.patch

File libwidg_fix_1_of_1_rev_c4547d964655_EditTextView__Fixed_long_standing_bug_with_inconsistent_cursor_position_after_select_word.patch, 1.7 KB (added by jan vrany, 7 years ago)
  • EditTextView.st

    # HG changeset patch
    # User Jan Vrany <jan.vrany@fit.cvut.cz>
    # Date 1489742033 0
    #      Fri Mar 17 09:13:53 2017 +0000
    # Branch jv
    # Node ID c4547d9646555ff4fcb9bc2c447afd756da0e334
    # Parent  da4954e52fd3ec5341a1b86cf9840aaf4f0fc354
    EditTextView: Fixed long standing bug with inconsistent cursor position after select-word
    
    If there's a selection, cursor position (`cursorLine` / `cursorCol` instvars)
    are required to be same as either selection start or selection end.
    
    #selectWordAtLine:col: did not update cursor position accordingly,
    leading to assertion failure. This bug has been there for a loong
    time. My bad, I was too lazy to fix it, until today...
    
    diff -r da4954e52fd3 -r c4547d964655 EditTextView.st
    a b  
    88588858    ]
    88598859!
    88608860
     8861selectWordAtLine:line col:col
     8862    "select the word at given line/col"
     8863    super selectWordAtLine:line col:col.
     8864    cursorLine := selectionEndLine.
     8865    cursorCol := selectionEndCol + 1.
     8866
     8867    "Created: / 16-03-2017 / 23:27:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     8868!
     8869
    88618870selectWordUnderCursor
    88628871    "select the word under the cursor"
    88638872
  • tests/EditTextViewTests.st

    diff -r da4954e52fd3 -r c4547d964655 tests/EditTextViewTests.st
    a b  
    4949    textViewInteractor type: #CtrlShiftCursorRight.
    5050    textViewInteractor type: #CtrlShiftCursorRight.
    5151
    52     self assert: textView selectionAsString = 'is Smalltalk'.
    53 
     52    self assert: textView selectionAsString = 'is Smalltalk '.
     53 
    5454    "Created: / 24-02-2015 / 08:21:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    5555! !
    5656