pharo-spec / NewTools

All development tools for Pharo, developed with Spec
21 stars 53 forks source link

Fix code highlighting in debug points browser, for debug points set on AST node #726

Closed adri09070 closed 5 months ago

adri09070 commented 6 months ago

Fixes #725

When you select a debug point in the debug point browser, it updates itself according to the target of the selected debug point.

In the case of an AST node, it updates the code presenter (code and highlighting) and updates its layout to display this code presenter:

DebugPointNodeTarget >> updateDebugPointUIManager: aDebugPointUIManager [

    aDebugPointUIManager updateCode: self.
    aDebugPointUIManager switchToNodeTargetView
]

DebugPointCodePresenter >> updateCode: aDebugPointNodeTarget [
    "updates the code window with the code of the selected debug point"
        ... 
    self ... ;
        addTextSegmentDecoration: 
            (SpTextPresenterDecorator forHighlight
                interval: (aDebugPointNodeTarget node start to: ((aDebugPointNodeTarget node stop) +1));
            yourself) .
]

DebugPointBrowserPresenter >> switchToNodeTargetView [

    self switchToTargetView: dpCode
] 

DebugPointBrowserPresenter >> switchToTargetView: aDebugPointTargetPresenter [
         "targetContainer is a SpPanedLayout"
    targetContainer replaceSecond: aDebugPointTargetPresenter
]

The method #updateCode: calls the method #addTextSegmentDecoration: that asks an adapter to add highlighting to the corresponding morphs.

However, for an obscure reason, SpPanedLayout>>#replaceSecond: called from DebugPointBrowserPresenter >> switchToNodeTargetView seems to replace the morphs corresponding to the presenter, and thus the highlight that was just added disappears.

To fix that, I just reversed the order of method calls in DebugPointNodeTarget >> updateDebugPointUIManager:. First, we display the code presenter (which replaces the morphs corresponding to the code presenter) and then we update this code presenter (we add the highlight). In this order, the highlight remains and is correct

adri09070 commented 6 months ago

@StevenCostiou

adri09070 commented 5 months ago

@StevenCostiou