Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1805: Disables editing the SharedBuffer when in readonly mode, #1827

Conversation

kylejwatson
Copy link

Disables Retab modifying the buffer in readonly mode
Fixes: #1805

Disables Retab modifying the buffer in readonly mode
toSpaces := b.Settings["tabstospaces"].(bool)
tabsize := util.IntOpt(b.Settings["tabsize"])
dirty := false
if !b.Type.Readonly {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be good as a temporary fix. But there is one more issue with Retab: it is not undoable. The reason is that if modifies the buffer directly, not via EventHandler, i.e. bypasses the undo stack. So it seems a final solution would be to change Retab to use EventHandler's Replace or MultipleReplace, and add readonly mode check for any replace operations.

b.isModified = true
b.HasSuggestions = false
b.LineArray.insert(pos, value)
if !b.Type.Readonly {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS the only reason for this is that MoveLinesUp calls this low-level insert function directly (which also, like in case with retab, causes another issue: undo doesn't work correctly for MoveLinesUp at the last line).
It was changed to use insert instead of Insert in the commit cfc595e. I wonder what was the reason for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Readonly mode doesn't disallow undo, replace, retab...
2 participants