Context menu Source code - Browse does not work correctly
Bug description The context menu "Source code - Browse" in the source code editor related to a given AST does not do what is expected. It opens the class to which the method belongs, not the class that is selected.
To Reproduce Steps to reproduce the behavior:
- go to
AIGraphAlgorithm>>#initialize - move the text cursor into the class name
SortedCollectionin the source code - RMB
- Select context menu Source code - Browse
- it opens a browser on the class
AIGraphAlgorithm, notSortedCollection
Note: the next menu item "Source code - Class refs." correctly words with the selected class. Version information:
- Pharo Version: Pharo 12.0.0 Build information: Pharo-12.0.0+build.616.sha.785370b5e81788061d5130e43565d1d9beef1731 (64 Bit)
One possible solution is:
SycBrowseClassCommand>>#prepareFullExecutionInContext: aToolContext
super prepareFullExecutionInContext: aToolContext.
targetClass := (Smalltalk classOrTraitNamed: aToolContext selectedSourceNode name) ifNil: [ aToolContext lastSelectedClass ]
However, maybe it is worth to consider to convert the class to inherit from SycClassCommand instead of SycSingleClassCommand and follow the implementation of ClyShowClassRefCommand that for a similar operation works as expected.
Thanks Pavel. I should say that I'm super frustrated with Pharo and the shortcut. Most of the time I want to see a browser on the class of the method and most of time I get Undefined or something like that. I looks like that nobody interact with the system the way I do not it and I just lose my time. it looks like nobody cares and each time I propose something it is not good. I was planning to create my own keybindings and say fuckoff to Pharo and I think that I will do it and do not care.
I will turn my notes that I took about this and make a presentation, then we can discuss much easier.
T problem is that CMD-B used to be "do-it and browse the class of the result". And as we eval first, it is very hard to add any intelligence to this mechanism... we need to really re-think it, we can not just patch it a little to reach what we want (and we need to define what we want exactly, too).