Sublime Forum

Read Only attribute should disallow saving

#1

I noticed when a view is set to read only via “view.set_read_only(True)”, you can still save the file. I do not think this should be allowed. I understand in most circumstances, a read only file if saved, would just save what was already there, but in my case, this is not true.

I am creating a plugin that converts the current view into hex allowing you to see the raw data. I protect the view by setting it to read only since this is just a viewer, but if a user accidentally hits save it will save the current hex view buffer to the file which is undesirable. This corrupts the file.

Currently I have to save the original buffer when showing hex view and on pre-save, reload the original buffer to make sure the file gets written properly. This works, but I think it should be unnecessary.

If a view is set to read only, I think it should only allow “save as”. It isn’t really read only if it allows you save.

0 Likes

#2

I would also be content with the ability to determine what kind of save (save or save as) is being called in “on_pre_save”, and then given the ability to cancel the save, but sadly this does not exist either.

0 Likes

#3

I am abandoning the method I was using before for a reasonable solution that gives the same feel. So this is no longer an issue for me.

But in general, I still think this is an issue. The read only flag does not protect against manual saves.

0 Likes