Skip to content

Possible data loss bug in close_view and close_window, plus new clone_view #147

@Thom1729

Description

@Thom1729

When using close_view or close_window with force=True, when a view is dirty and not scratch, the function will make the view scratch before closing it. But because scratchness is a buffer property, if there were other clones of that view, they will also be made scratch after the function is done. This could indirectly result in data loss.

The remedy is to keep track of what buffers close_view and close_window set to scratch and revert them afterward. I think that the original behavior is a bug, and the change in behavior is justified as a fix.

Anyway, when testing this, we need to create our own cloned views. Apparently the API doesn't provide anything like view.clone() — you have to:

  1. Activate the view you want to clone.
  2. Send the clone_file command to the window.
  3. Return the active view.

This seems overcomplicated and (possibly) prone to race conditions. I wonder if there's a better way to do it. I also wonder whether a function that does it whatever way is best would be a good sublime_lib feature. See sublimehq/sublime_text#3963.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions