meganrogge / template-string-converter

Autocorrect from quotes to backticks
MIT License
190 stars 24 forks source link

Bug with undoing changes - deletes the history of changes! #47

Closed lukaszpolowczyk closed 3 years ago

lukaszpolowczyk commented 3 years ago

Bug with undoing changes - deletes the history of changes!

Steps to reproduce:

  1. I type the template string with $ {dd} in it
  2. Delete the dollar stamp $
  3. I type something else in the code
  4. Undo changes - do Ctrl + Z
  5. Undo gets stuck - I can't undo or redo changes It deleted the history of changes!

Steps on the gif: template string extension bug2

This is very painful because, for example, I check the previous version of something (undo), then I want to go back to the newest (redo) and they can't, my work has been wasted!

For now, I am disabling the extension because it is dangerous.

Solution: An extension shouldn't fire its function when you use undo/redo, but just like manually typing or pasting the code.

meganrogge commented 3 years ago

Looks like you have the setting template-string-converter.autoRemoveTemplateString which seems to cause this issue. I'd reccomend turning that off (I personally don't use it).

lukaszpolowczyk commented 3 years ago

@meganrogge Yes, I used this option. Either remove this option or it needs to be repaired.

You closed the topic right away, so you probably don't plan on fixing it?

meganrogge commented 3 years ago

I was not/am not a fan of that setting for the reason you pointed out and others. I closed this bc I don't think the extension should try to track whether or not the $ was removed. You'll see in the original feature request, I pointed out my concerns about doing that. I think the setting should be off for most users.

lukaszpolowczyk commented 3 years ago

"I don't think the extension should try to track whether or not the $ was removed."

That this option should be removed - I understand that. You don't want to support her, that's it.

But you can see what happens when I modify the code normally - the edit change history is deleted! In Svelte.js, I changed the string template to a regular mustache - that's why I removed the dollar sign. Later I checked something with the previous version of the code. When I wanted to go back, the story got stuck on erasing the dollar sign.

This is a really sneaky and malicious function when it goes wrong.

meganrogge commented 3 years ago

I agree, which is why I have that setting off by default.

I will probably add a warning about this in the setting description. Will that be sufficient for you?

lukaszpolowczyk commented 3 years ago

@meganrogge Well, if there's nothing else you can do. Better to remove it completely, because it is not functional and is dangerous.

meganrogge commented 3 years ago

Yeah I think you're right. I'll consider what to do, but might remove it entirely.

meganrogge commented 3 years ago

done - it's removed as of the next version. probably the right call, thanks for bringing this to my attention

xNocken commented 3 years ago

The issue should be fixed now