Skip to content

small fix on NewTools-Spotter-Processors -> stQuery >> updatefromContext#1146

Merged
Ducasse merged 1 commit intoPharo14from
stquery-update-from-context-small-fix
Jun 24, 2025
Merged

small fix on NewTools-Spotter-Processors -> stQuery >> updatefromContext#1146
Ducasse merged 1 commit intoPharo14from
stquery-update-from-context-small-fix

Conversation

@SebastianLorenzano
Copy link
Member

sometimes, aSpotterContext search can give back a Text object insteaad of a string, which doesn't understand the substrings: message, so I'm making sure that in textParts he always uses texts asString to make sure it doesn't happen :)

… of a string, which doesn't understand the substrings: message, so I'm making sure that in textParts he always uses texts asString to make sure it doesn't happen
@Ducasse
Copy link
Contributor

Ducasse commented Jun 21, 2025

Ok could you chase why we get a Text instead of String?
You can put a self haltIf: [ x class = Text] this break point will only stop on demand.

@SebastianLorenzano
Copy link
Member Author

@Ducasse For what I've seen, it has to do with the styles it has attached: When you are writing on the playground, it uses a text to be able to carry the style of the string (for eg. when it doesn't find a selector and it paints itself red). So, when you insert the selection, it actually gets a Text instead of a String. It is not a case that happens always but it does happen in those cases, which was throwing me an exception before the change

@@ -112,7 +112,7 @@ StQuery >> updateFromContext: aSpotterContext [

modifiers removeAll.
texts := (aSpotterContext search ifNil:[ '' ]) trimBoth.
Copy link
Contributor

Choose a reason for hiding this comment

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

Now I do not get because trimBoth is not defined on Text so it should break here.

@Ducasse
Copy link
Contributor

Ducasse commented Jun 24, 2025

@SebastianLorenzano
could you do the following:

introduce trimBoth, and friends (trimLeft trimRight I checked) there is trim in Text) to the class Text) with tests?

This way we will have Text and String polymorphic and then we could check all the trim users and get rid of the conversion?
@jecisc What do you think cyril.
We got several bugs because of this.
The trim API was introduced but only in String it was clearly an error.

S.

@jecisc
Copy link
Member

jecisc commented Jun 24, 2025

I think it makes sense to have trimming in Text. But probably not for spotter. In spotter I'd use an "asString" when we set the value of the field to be sure to manipulate a string everywhere in spotter model. I don't see why Spotter would need the styling

@Ducasse
Copy link
Contributor

Ducasse commented Jun 24, 2025

Ok I will integrate it.
I did a PR for improving the text API.

@Ducasse Ducasse merged commit 9f8a12b into Pharo14 Jun 24, 2025
0 of 2 checks passed
@jecisc jecisc deleted the stquery-update-from-context-small-fix branch June 25, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants