Ticket #124: libwidg_fix_1_of_1_rev_ef289d40b266_Issue__124__case_0__Fixed_long_standing_bug_with_inconsistent_cursor_position_after_select_word.patch

File libwidg_fix_1_of_1_rev_ef289d40b266_Issue__124__case_0__Fixed_long_standing_bug_with_inconsistent_cursor_position_after_select_word.patch, 2.0 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 ef289d40b266f762c0295507234b78d6c7091408
    # Parent  da4954e52fd3ec5341a1b86cf9840aaf4f0fc354
    Issue #124, case 0: 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...
    
    https://swing.fit.cvut.cz/projects/stx-jv/ticket/124
    
    diff -r da4954e52fd3 -r ef289d40b266 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 ef289d40b266 tests/EditTextViewTests.st
    a b  
    1414setUp
    1515    | topView |
    1616
    17     Smalltalk loadPackage: 'stx:goodies/sunitext/ui'.
     17    Smalltalk loadPackage: 'stx:goodies/sunit/ext/ui'.
    1818
    1919    topView := StandardSystemView new.
    2020    topView extent: 320 @ 200.
     
    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