Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error loading Syntax File when running GitSavvy: Help #1028

Closed
RitikShah opened this issue Oct 24, 2018 · 13 comments · Fixed by #1315
Closed

Error loading Syntax File when running GitSavvy: Help #1028

RitikShah opened this issue Oct 24, 2018 · 13 comments · Fixed by #1315
Labels

Comments

@RitikShah
Copy link

Sublime Text: Version 3.1.1 Build 3176
Git version 2.17.1 (Apple Git-112)
Mac OS Mojave (10.14)
Error: Error loading syntax file "Packages/Markdown/Markdown.sublime-syntax": Apparent recursion within a with_prototype action: 25000 context sanity limit hit

Description: When I run, GitSavvy: Help in sublime text, the text shows, but the markdown does not.
Steps:

  1. Install GitSavvy via Sublime
  2. Run Gitsavvy: Help

Log: [] (it had nothing, not sure why) (The error message pop-up is all I get)

@asfaltboy
Copy link
Member

I had the same issue and I followed this thread jonschlinkert/sublime-markdown-extended#141 to find the solution that worked for me: disable the package "JavaScriptNext - ES6 Syntax". Your case might be different...

@asfaltboy
Copy link
Member

I guess the JSON code snippet in the first help page fools sublime to believe JS syntax should be set. Perhaps we could "force set" a markdown syntax (if available) falling back to plain text?

@rchl
Copy link

rchl commented Jun 18, 2020

I can see this happening in ST4 now.

The help file opens as Plain Text and the navigation functionality does not work.

Since the opened view has a name GITSAVVY HELP and no extension, I think it only makes sense to assign the syntax manually rather than relying on content being auto-detected.

@kaste
Copy link
Collaborator

kaste commented Jun 18, 2020

Hi!

We actually assign a syntax, or try to. I know your savvy so could you run

>>> import GitSavvy
>>> GitSavvy.common.util.file.syntax_file_map["md"]

On my machine this returns ['Packages/Markdown/Markdown.sublime-syntax'].

@rchl
Copy link

rchl commented Jun 18, 2020

That actually gives a key error so there is no md in the map.

I do have default Markdown syntax and I can set it manually. Then the syntax setting is Packages/Markdown/Markdown.sublime-syntax

@rchl
Copy link

rchl commented Jun 18, 2020

I've looked at how you set up the map at

def _determine_syntax_files():
syntax_files = sublime.find_resources("*.sublime-syntax")
for syntax_file in syntax_files:
try:
# Use `sublime.load_resource`, in case Package is `*.sublime-package`.
resource = sublime.load_resource(syntax_file)
for extension in yaml.safe_load(resource)["file_extensions"]:
if extension not in syntax_file_map:
syntax_file_map[extension] = []
extension_list = syntax_file_map[extension]
extension_list.append(syntax_file)
except Exception:
continue
and while I'm not 100% sure, I feel this could be due to timing issues and sublime.find_resources("*.sublime-syntax") not returning all files if called early at load since the database of files is still loading. Could be that it triggers only when there are many files (I have many since I have a lot of .git directories in symlinked packages).

@kaste
Copy link
Collaborator

kaste commented Jun 19, 2020

We have a broad try except clause here so we actually can't know. Have you GitSavvy checked out (or packaged), then you could look into it. load_resource or yaml.safe_load could fail here as well. Could be a ST4 regression too.

@rchl
Copy link

rchl commented Jun 19, 2020

It doesn't fail. It's just that the GitSavvy.common.util.file.syntax_file_map list is not complete. It has many items but not markdown.

@kaste
Copy link
Collaborator

kaste commented Jun 19, 2020

You patched GitSavvy to confirm that nothing fails here?

@rchl
Copy link

rchl commented Jun 19, 2020

Oh, I see what you mean now. It can fail for each syntax separately. I'll check it out.

@rchl
Copy link

rchl commented Jun 19, 2020

It fails for a lot of syntaxes but when it comes to Markdown the exception is:

could not determine a constructor for the tag 'tag:yaml.org,2002:value'
  in "<unicode string>", line 1496, column 14:
        - match: =
                 ^ Packages/Markdown/Markdown.sublime-syntax

More context for that line:

  tag-attr-equals:
    - match: =
      scope: punctuation.separator.key-value.markdown
      set: tag-attr-value
    - include: else-pop

@kaste
Copy link
Collaborator

kaste commented Jun 19, 2020

Okay, for ST4 we can use new API endpoints mentioned here: sublimehq/sublime_text#2186 (comment)

@kaste
Copy link
Collaborator

kaste commented Jun 19, 2020

For ST3, we could naive parse e.g. extract full match from ^file_extensions:\n((.*\n)+?)^(?=\w) and put it into yaml.safe_load(s).

kaste added a commit that referenced this issue Jun 20, 2020
Fixes #1028

For a lot of files `yaml.safe_load` fails if the lib does not support
the used yaml format.  It is also very slow to parse all syntax files.

Since we only use relatively simple information here, t.i. a single
key, we just run a regex and extract the useful information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants