Skip to content

Commit

Permalink
Changing tabs saves method without updating multiverse
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Jan 26, 2024
1 parent 9e659df commit f7b6835
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 37 deletions.
52 changes: 19 additions & 33 deletions packages/Sandblocks-Babylonian/SBExploriants.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Class {
#instVars : [
'objectToPermutation',
'updateProcess',
'updateProcessRunning'
'updateProcessRunning',
'ignoreUpdate'
],
#classInstVars : [
'uniqueInstance'
Expand Down Expand Up @@ -88,6 +89,18 @@ SBExploriants >> evaluationReceiver [
^ self object
]

{ #category : #accessing }
SBExploriants >> ignoreUpdate [

^ ignoreUpdate
]

{ #category : #accessing }
SBExploriants >> ignoreUpdate: aBoolean [

ignoreUpdate := aBoolean
]

{ #category : #initialization }
SBExploriants >> initialize [

Expand All @@ -114,34 +127,6 @@ SBExploriants >> objectToPermutation [
^ objectToPermutation
]

{ #category : #actions }
SBExploriants >> onlySwitchedTabsIn: aMethodBlock multiverse: aMultiverse [

| methodClass methodSelector latestChange diff changes |
(aMultiverse allMethodBlocksContainingVariants includes: aMethodBlock)
ifFalse: [^ false].

methodClass := aMethodBlock compiledMethod methodClass.
methodSelector := aMethodBlock compiledMethod selector.
latestChange := (ChangeSet
scanVersionsOf: aMethodBlock compiledMethod
class: methodClass
meta: methodClass isMeta
category: (methodClass organization categoryOfElement: methodSelector)
selector: methodSelector) second.
diff := TextDiffBuilder new
from: aMethodBlock compiledMethod getSource
to: latestChange text.
changes := OrderedCollection new.
diff patchSequenceDoIfMatch: [ :string |]
ifInsert: [ :string | changes add: string]
ifRemove: [ :string| changes add: string].
^ (changes allSatisfy: [:aString | aString matchesRegex: '\s*activeIndex\: \d*\s*']).



]

{ #category : #'artefact protocol' }
SBExploriants >> saveTryFixing: aFixBoolean quick: aQuickBoolean [

Expand All @@ -160,11 +145,12 @@ SBExploriants >> tryToUpdateInBackgroundAfterChangeIn: aMethodBlock [

| multiverse |
multiverse := self active multiverse.
(self onlySwitchedTabsIn: aMethodBlock multiverse: multiverse)
ifTrue: [ [self sandblockEditor sendNewPermutationNotification] forkAt: Processor userBackgroundPriority.
^ self].
self ignoreUpdate
ifFalse: [self updateInBackgroundOnTimeoutRevertTo: multiverse]
ifTrue: [
[self sandblockEditor sendNewPermutationNotification] forkAt: Processor userBackgroundPriority.
self ignoreUpdate: false.]

self updateInBackgroundOnTimeoutRevertTo: multiverse


]
Expand Down
17 changes: 15 additions & 2 deletions packages/Sandblocks-Core/SBTabView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ SBTabView >> asTabButton: aNamedBlock [
^ button
]

{ #category : #tabs }
SBTabView >> basicSetActive: aNamedBlock [

self sandblockEditor do:
(self switchCommandFor: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1)).

]

{ #category : #accessing }
SBTabView >> blockAt: anIndex [

Expand Down Expand Up @@ -387,8 +395,13 @@ SBTabView >> removeCurrentTab [
{ #category : #tabs }
SBTabView >> setActive: aNamedBlock [

self sandblockEditor do:
(self switchCommandFor: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1))
(self containingArtefact hasUnsavedChanges and: [self containingArtefact isMethod])
ifTrue: [self basicSetActive: aNamedBlock]
ifFalse: ["changing tabs is latest change"
self basicSetActive: aNamedBlock.
SBExploriants uniqueInstance ignoreUpdate: true.
self sandblockEditor save: self containingArtefact tryFixing: false quick: true.].

]

{ #category : #commands }
Expand Down
2 changes: 0 additions & 2 deletions packages/Sandblocks-Utils/SBPermutation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ SBPermutation >> activeScore [
SBPermutation >> apply [

self referencedVariants do: [:aVariant | aVariant switchToAlternative: (self at: aVariant id)].
(Set newFrom: (referencedVariants collect: #containingArtefact thenSelect: #isMethod))
do: [:aMethodBlock | aMethodBlock sandblockEditor save: aMethodBlock tryFixing: true quick: true].
((Set newFrom: (referencedVariants collect: #sandblockEditor))
reject: #isNil)
do: #sendNewPermutationNotification
Expand Down

0 comments on commit f7b6835

Please sign in to comment.