liamcain / AutoFileName

Sublime Text plugin that autocompletes filenames
514 stars 78 forks source link

cant't work on sublime 4100 #121

Open jingyuexing opened 3 years ago

jingyuexing commented 3 years ago

the error log:

Traceback (most recent call last):
  File "I:\Programming\sublime_text_4100\Data\Installed Packages\LSP.sublime-package\plugin/core/windows.py", line 500, in _update_panel_main_thread
    panel.run_command("lsp_update_panel", {"characters": characters})
  File "I:\Programming\sublime_text_4100\Lib\python33\sublime.py", line 1304, in run_command
    sublime_api.view_run_command(self.view_id, cmd, args)
  File "I:\Programming\sublime_text_4100\Lib\python33\sublime_plugin.py", line 1490, in run_
    self.view.end_edit(edit)
  File "I:\Programming\sublime_text_4100\Lib\python33\sublime.py", line 1265, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "I:\Programming\sublime_text_4100\Lib\python33\sublime_plugin.py", line 924, in on_modified
    run_view_callbacks('on_modified', view_id)
  File "I:\Programming\sublime_text_4100\Lib\python33\sublime_plugin.py", line 708, in run_view_callbacks
    callback(v, *args)
  File "I:\Programming\sublime_text_4100\Lib\python33\sublime_plugin.py", line 152, in profiler
    return event_handler(*args)
  File "I:\Programming\sublime_text_4100\Data\Installed Packages\AutoFileName.sublime-package\autofilename.py", line 162, in on_modified
    sel = view.sel()[0].a
  File "I:\Programming\sublime_text_4100\Lib\python33\sublime.py", line 1012, in __getitem__
    raise IndexError()
IndexError
leandro27 commented 3 years ago

I'm using Sublime 4104 and this worked for me: Open autofilename.py, using PackageResourceView. Go to line 162, and instead of

sel = view.sel()[0].a
txt = view.substr(sublime.Region(sel-4,sel-3))
if (self.showing_win_drives and txt == FileNameComplete.sep):
    self.showing_win_drives = False
    view.run_command('afn_delete_prefixed_slash')

Use:

try:
    sel = view.sel()[0].a
    txt = view.substr(sublime.Region(sel-4,sel-3))
    if (self.showing_win_drives and txt == FileNameComplete.sep):
        self.showing_win_drives = False
        view.run_command('afn_delete_prefixed_slash')

except IndexError:
    pass