[Cuis-dev] Fwd: Undoing after Saving

Juan Vuletich juan at jvuletich.org
Mon Oct 28 13:46:35 PDT 2019


Hi Santiago,

On 10/27/2019 2:53 PM, Santiago Dandois via Cuis-dev wrote:
>
> Hi,
>
> I've been using Cuis for a while, and there's something that felt 
> bothersome to me: you cannot do Ctrl-z to undo changes after saving a 
> method. Then I thought I could fix it myself.
>
> After doing some research, this is what I found about what is happening:
>
> When you do (C-S) to save a text, then the message #acceptContents is 
> sent to
> the InnerTextMorph.
>
> The method for this messages, calls `model refetch`, being model a 
> PlugglableTextModel. Then, the method for this message calls,
> `self actualConents: (textProvider perform: textGetter).` (Sort of).
>
> And finally, in the TextModel actualContents: implementation,
> the undoRedoCommands is being reset.
>
> I found out two possible solutions to this issue (Changes attached).
>
> The first one I called it "The Safe One". In this solution, I modify 
> the actualContents: method to check if the nextActualContets received 
> as a parameter is equal to the actualContents before the message was 
> sent. If so, I just keep the undoRedoCommands as they are.

I've integrated this one. I made a modification to reuse existing code, 
but kept your initials. I also added you to the known code authors.

>
> Then I thought that since the text actually didn't change ,there may 
> not be any need to do the refetching. This seems to be working also, 
> but I since I cannot understand why there was a refetch in the first 
> place, I fear I'am missing something. Moreover, there is a comment 
> warning about this.

Yes. The text that is retrieved from the model might be different from 
the one the user just saved. For example, click the rightmost button in 
the browser, [show...] and select [prettyPrint]. After you save, code is 
automatically formatted. If you remove the refetch, this is no longer done.

>
> I hope you found this contribution helpful.

Nice and useful. Thanks!

>
> Cheers,
>    Santiago José Dandois

Cheers,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich



More information about the Cuis-dev mailing list