braver/SideBarTools

NoneType error on OSx

gerardroche opened this issue · 2 comments

re: gerardroche/NeoVintageousFiles#2

NeoVintageousFiles has a dependency on SideBarTools. The new folder command is throwing a NoneType error.

This happens when you try to create a new folder when the active view/pane is blank/empty.

Reproduction

  • Create an empty view/pane.
  • Create new folder via NeoVintageousFiles (press A when focus is on the sidebar)
command: neovintageous {"action": "toggle_side_bar"}
command: toggle_side_bar
command: focus_side_bar
chr evt: A (0x41)
command: neovintageous_files_new_folder
command: side_bar_new {"paths": []}
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python38/sublime_plugin.py", line 1647, in run_
    return self.run(**args)
  File "/Users/chris/Library/Application Support/Sublime Text/Installed Packages/SideBarTools.sublime-package/SideBar.py", line 300, in run
  File "./python3.8/genericpath.py", line 42, in isdir
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
reloading settings Packages/User/Preferences.sublime-settings

Relevant line: https://github.com/braver/SideBarTools/blob/master/SideBar.py#L300

Looks like get_path() will return None if the current active view is not a real file on disk.

I'm not sure there is any way to fix this is there? Because until the file name or directory is passed to the command, which is what happens when you use the mouse right click menu, then there is no way for the command discover the path.

Currently, if the file name or directory is not passed, it uses the active view. But if that is not a real file on disk, then it's None.

So this might be a can't fix?

  • ST4 (
  • SideBarTools (1.12.2)

I believe there is a way to check if a view is a file on disk, and otherwise it sounds like something that might be try-catched. Let’s have a look 😊

@gerardroche can you check if #56 would help?