Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

adri09070
Copy link
Contributor

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 adri09070 added bug Something isn't working debugger labels Mar 21, 2024
@adri09070 adri09070 requested a review from StevenCostiou March 21, 2024 14:41
@adri09070
Copy link
Contributor Author

@StevenCostiou

Copy link
Member

@jecisc jecisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me. Should I merge?

@adri09070
Copy link
Contributor Author

@StevenCostiou

@jecisc jecisc merged commit b4cea87 into pharo-spec:Pharo12 Apr 15, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working debugger
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Debug Point Browser does not highlight corresponding code when a debug point is attached to a node
3 participants