Sublime Forum

Disable destructive operations?

#1

I sometimes click on “Discard Hunk” or “Discard” on another file when I mean to discard the selected lines on the file below it. Normally I only ever discard selected lines because I too often made mistakes when using these other Discard buttons (I hate that they are fixed so their target file changes as you scroll even though they don’t move). Worst of all, these destructive actions can’t be undone.

So my question is, is there any way to disable or hide these buttons? Maybe some config hack that I can use for this?

0 Likes

#2

In Merge’s defence, they make you click that button twice before it takes affect. You should really double check what you are doing is what you actually want to do instead of just clicking the button twice.

0 Likes

#3

Yes but you need to click the “Discard lines” button twice too so in any case you intent to click whatever button you’re going to click twice.

I rarely make a mistake but it can happen and as often with software development, you can blame the user or you can try to improve the software.

1 Like

#4

I’m not sure how it could be improved more. I would be surprised to see a feature that disables integral features such as discarding hunks and such.

Maybe there is a hack you can do, but I’m not aware of one :man_shrugging:.

0 Likes

#5

It might be possible to modify the theme to hide the button, but I’m not sure if it’s granular enough to just hide only the discard button.

If anything, maybe adding extra spacing between the two rows of buttons could help you.

0 Likes

#6

Yeah, I thought about this, but I don’t know that you have control over each button, I think it is more styling of buttons in general :man_shrugging:.

0 Likes

#7

Hmm, thanks for the info, although it looks like there’s no easy solution. I might look at theme customisation just in case, but of course a built-in solution would be even better.

0 Likes

#8

You are totally right here. I’ve discarded changes in a whole file (ugh) when I was meaning to discard a single hunk instead. The UI is definitely designed poorly in this regard.

It’s happened to me multiple times.

Thankfully, when I did that, the file was still open in Sublime Text, and I was able to go to the file and “undo” the change.

I wonder what the best way to alert the Sublime Merge author of this is?

0 Likes

#9

Well I’ve ended up on my own post after accidentally clicking “Discard Hunk” instead of “Discard Lines” once again and searching for a way to prevent that. Thankfully I had a backup of my changes.

But I’m wondering since Sublime Merge makes these destructive actions so easy, perhaps it should also provide an easy way to undo them? I guess just before pressing any Discard button, it could save to memory a copy of the file (or a diff), then if the user made a mistake, the changes can be undone.

I can’t imagine that would be that difficult to implement and it would certainly make Sublime Merge a lot safer to use.

0 Likes

#10

There should be at least some wider spacing between destructive menu options to make it harder to click the wrong thing.

1 Like

#11

Once again I accidentally lost content thanks to Sublime Merge confusing UI when it comes to destructive operations.

I almost never use “Discard Hunk” and instead I select the lines I want to discard and click on “Discard line”. Now the tricky part is that if no lines are selected ST changes the “Discard line” button to “Discard hunk”, so what happened is that I place the cursor on the line I wanted to discard, but since it wasn’t selected, the button became “Discard hunk” and I lost the whole block.

As always - yes my mistake, but I use ST hundreds of times each week and given how confusing the UI is, I will probably keep making mistakes now and then. ST seriously needs to consider improving this

0 Likes