jtojnar / sublime-image-link-insertion

Sublime Text package for quick insertion of many images into markdown document
MIT License
0 stars 0 forks source link

Plugin fails on file selection #1

Open reagle opened 1 year ago

reagle commented 1 year ago

macOS 13.4 22F66 arm64 ST4143

Hi, thanks for this! I gave it a try but upon selecting a file, nothing happens and a bunch of errors appear in the console. I'm not sure why I'm seeing tracebacks on other plugins...?

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1340, in is_enabled_
    raise ValueError("is_enabled must return a bool", self)
ValueError: ('is_enabled must return a bool', <BracketHighlighter.bh_rules.BhDebugRuleCommand object at 0x102db42b0>)
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1378, in is_checked_
    raise ValueError("is_checked must return a bool", self)
ValueError: ('is_checked must return a bool', <BracketHighlighter.bh_core.BhDebugCommand object at 0x102d20b70>)
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1354, in is_visible_
    ret = self.is_visible()
  File "/Users/reagle/Library/Application Support/Sublime Text/Packages/Mediawiker/mediawiker.py", line 110, in is_visible
    return utils.props.get_view_setting(self.window.active_view(), 'is_here')
  File "/Users/reagle/Library/Application Support/Sublime Text/Packages/Mediawiker/mwcommands/mw_properties.py", line 303, in get_view_setting
    return key_type(view.settings().get(key, default_value))
AttributeError: 'NoneType' object has no attribute 'settings'
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 940, in on_activated
    run_view_callbacks('on_activated', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 708, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 152, in profiler
    return event_handler(*args)
  File "/Users/reagle/Library/Application Support/Sublime Text/Packages/rainbow_csv/main.py", line 903, in on_activated
    run_rainbow_autodetect(view)
  File "/Users/reagle/Library/Application Support/Sublime Text/Packages/rainbow_csv/main.py", line 869, in run_rainbow_autodetect
    if not is_plain_text(view):
  File "/Users/reagle/Library/Application Support/Sublime Text/Packages/rainbow_csv/main.py", line 306, in is_plain_text
    if syntax.find('Plain text.tmLanguage') != -1:
AttributeError: 'NoneType' object has no attribute 'find'
jtojnar commented 1 year ago

Hi, I think this is probably the https://github.com/sublimehq/sublime_text/issues/5830 and the other tracebacks are unrelated.

Reportedly, the following patch might work around it but I have been unable to reproduce the bug with enough regularity to be able to confirm if it does:

--- a/ChooseImagesCommand.py
+++ b/ChooseImagesCommand.py
@@ -20,6 +20,9 @@ class ImageLinkInsertionChooseImagesCommand(sublime_plugin.TextCommand):
         )

     def handle_response(self, files):
+        sublime.set_timeout(lambda: self.handle_response_real(files), 100)
+
+    def handle_response_real(self, files):
         if files is not None:
             self.view.run_command(
                 "image_link_insertion_insert_images",