Skip to content

TypeError when the tab has no file name #13

Open

Description

@dpc00

Claude reports:

Running BeautifyRust in a tab that has no file name (an unsaved tab with Rust syntax) raises a TypeError. Sublime Text build 4215, Windows 11, tested with v0.3.0 and with a copy of master (same code).

run does self.filename = self.view.file_name() and then os.path.basename(self.filename); file_name() is None for an unsaved tab. Console:

File ".../BeautifyRust.py", line 33, in run
    self.fname = os.path.basename(self.filename)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Fix I tested, in a folder copy of master: right after self.filename = self.view.file_name() add

if not self.filename:
    return sublime.status_message("Beautify rust: save the file first.")

With it the same command in the same tab prints no error.

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