Skip to content

AttributeError when the window has no open view (active_view() is None) #34

Open

Description

@dpc00

Running "Distraction Free Window" in a window that has no open tab raises AttributeError: 'NoneType' object has no attribute 'settings', because w.active_view() is None and is dereferenced without a check:

if w.active_view().settings().get('is_widget', False):

Reproduced with the package code (Sublime stubbed, active_view() returning None, which is what Sublime does for a window with no files):

window has no open view   AttributeError: 'NoneType' object has no attribute 'settings'

This makes it impossible to enter distraction-free mode from an empty window (e.g. right after opening a folder in the sidebar, which is a natural time to use it).

Fix: check view = w.active_view() for None first (and either continue without the widget check or show the status message).

Found while testing packages from the Package Control catalog.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions