Skip to content

Commit

Permalink
make cursor positioning after set text does not break selection behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanlm committed Nov 18, 2024
1 parent 2eb21be commit 982dda7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ SpMorphicBaseTextAdapter >> setSelection: interval [
{ #category : 'selection' }
SpMorphicBaseTextAdapter >> setSelectionFromModel: aSelection [

self widget ifNotNil: [ :w | w setSelection: aSelection ]
self widget ifNotNil: [ :w |
w setSelection: (aSelection ifNil: [ 1 to: 0 ]) ]
]

{ #category : 'initialization' }
Expand Down
5 changes: 3 additions & 2 deletions src/Spec2-Adapters-Morphic/SpMorphicTextAdapter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ SpMorphicTextAdapter >> buildWidget [
ifNotEmpty: [ :anInterval | self selectionInterval: anInterval on: newWidget ]
ifEmpty: [
self presenter text ifNotNil: [ :aString |
self cursorPositionIndex: aString size + 1 to: newWidget ] ].

self cursorPositionIndex: aString size + 1 to: newWidget.
self selectionInterval: (aString size + 1 to: aString size) on: newWidget ]. ].

self setWrapWord: self presenter isWrapWord to: newWidget.
self setUndoRedo: self presenter hasUndoRedoHistory to: newWidget.
self presenter whenSelectionChangedDo: [ :selectionInterval |
Expand Down
4 changes: 1 addition & 3 deletions src/Spec2-Backend-Tests/SpAbstractTextAdapterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,5 @@ SpAbstractTextAdapterTest >> testSelectionIntervalNilUnselectsEverything [

self openInstance.

self
assert: presenter adapter selectionInterval
equals: (1 to: 0)
self assert: presenter adapter selectionInterval isEmpty
]

0 comments on commit 982dda7

Please sign in to comment.