randy3k / Terminus

Bring a real terminal to Sublime Text
https://packagecontrol.io/packages/Terminus
MIT License
1.38k stars 84 forks source link

Undo stack is randomly cleared on non-Terminus views #313

Closed willrowe closed 2 years ago

willrowe commented 2 years ago

https://github.com/randy3k/Terminus/blob/fc0b132eae5a1118081bd97d167f53aa3c2c477f/terminus/commands.py#L489-L497

Due to this code, the undo stack in non-Terminus views will be randomly cleared. The conditional at the top is hard to parse initially, but it seems that the rest of the code in this method will only run if:

  1. The view is not a widget OR
  2. The view is a Terminus view

This means that any non-widget view will have its undo stack cleared.

jfcherng commented 2 years ago

Is view.settings().get("is_widget", False) and \ necessary?

willrowe commented 2 years ago

You can have a terminal in a panel or a full view, so I am not sure if it is trying to only target one of those cases. Either way, greater care needs to be taken when calling clear_undo_stack to ensure that it is only clearing Terminus views.

randy3k commented 2 years ago

Thanks for reporting it. A fix is on the way. I have changed the logic a bit edc4e30. It was meant to be and or condition.

randy3k commented 2 years ago

Fixed in v0.3.21 and it is on the way to Package Control.

willrowe commented 2 years ago

I'm not seeing a v0.3.21, but it looks like v0.3.20 was removed so I uninstalled and reinstalled and v0.3.19 was installed, effectively reverting the breaking code.

randy3k commented 2 years ago

Ya, I have removed v0.3.20 as it'll break a lot of people. v0.3.21 should be ready soon from package control. (I forgot to push the tag to github)

willrowe commented 2 years ago

Thanks so much @randy3k! I can confirm it is no longer clearing the undo stack on non-Terminus views.

randy3k commented 2 years ago

I am sorry about the bug. Shouldn't make a release without testing at the first place.