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

Need to redefine the entire "sublime-setting" default configuration to use custom configuration #122

Closed
adoussot opened this issue Mar 21, 2018 · 11 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@adoussot
Copy link

adoussot commented Mar 21, 2018

How can the issue be reproduced

  • copy/paste the Github Configuration from documentation to MarkdownTOC.sublime-settings
     {
       "defaults": {
         "autolink": true,
         "bracket": "round",
         "lowercase": "only_ascii"
       }
     }
  • save MarkdownTOC.sublime-settings
  • save a markdown file prefix by <!-- MarkdownTOC --> header

What was expected

  • should apply the github configuration to the saved file and generate the Toc OR the github configuration should be either removed from documentation or completed to redefine the entire default configuration

What actually occurred

  • in the file presenter: nothing occurs

  • in the console: the below exception occurs

    Traceback (most recent call last):
      File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 818, in run_
        return self.run(edit)
      File "markdowntoc.markdowntoc_update in C:\Users\Alexis\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 6, in run
      File "markdowntoc.markdowntoc_insert in C:\Users\Alexis\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 94, in find_tag_and_insert
      File "markdowntoc.markdowntoc_insert in C:\Users\Alexis\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 189, in get_toc
    KeyError: 'levels'
    
    • if I add the "levels": [1,2,3,4,5,6], configuration field to MarkdownTOC.sublime-settings and resave the file. I have the below exception
    Traceback (most recent call last):
      File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 818, in run_
        return self.run(edit)
      File "markdowntoc.markdowntoc_update in C:\Users\Alexis\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 6, in run
      File "markdowntoc.markdowntoc_insert in C:\Users\Alexis\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 94, in find_tag_and_insert
      File "markdowntoc.markdowntoc_insert in C:\Users\Alexis\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 212, in get_toc
    KeyError: 'remove_image'
    
    • etc. until the default configuration is redefined

What was the version of the involved component

  • last release version: v2018.03.21.06.27.10 (indicate in sublime "List package" menu)
@tajmone
Copy link

tajmone commented Mar 21, 2018

I think that MarkdownTOC just stopped working with the latest ST update (ST3157).

I've used MarkdownTOC without any problems until today, when it just stopped working, and I didn't change anything in the settings. It's simply not working with files that used it for TOC maintainance up to today.

I get very similar errors from the console:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 999, in run_
    return self.run(edit)
  File "markdowntoc.markdowntoc_update in C:\Users\P.K.Dick\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 6, in run
  File "markdowntoc.markdowntoc_insert in C:\Users\P.K.Dick\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 85, in find_tag_and_insert
  File "markdowntoc.markdowntoc_insert in C:\Users\P.K.Dick\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 66, in get_toc_open_tag
  File "markdowntoc.markdowntoc_insert in C:\Users\P.K.Dick\AppData\Roaming\Sublime Text 3\Installed Packages\MarkdownTOC.sublime-package", line 383, in get_attributes_from
KeyError: 'lowercase_only_ascii'

The KeyError seems to show up just with any settings.

@tajmone
Copy link

tajmone commented Mar 21, 2018

I didn't set any custom settings in my User file, but I use inline settings in the comment tags:

<!-- MarkdownTOC autolink="true" bracket="round" autoanchor="false" lowercase="true" lowercase_only_ascii="true" uri_encoding="true" depth="3" -->

<!-- /MarkdownTOC -->

And this produces the error pasted above.

But if I use the plain tags, without options, it works.

Something seems to have changed in the way ST runs the MarkdownTOC code that parses tags settings.

So it seems that the issue reported by @adoussot and the one I'm facing are both linked to a more general problem due to ST update.

@adoussot
Copy link
Author

adoussot commented Mar 21, 2018

depth and lowercase_only_ascii are deprecated since the today release. We have either to use the level (and lowercase) attribute or remove it. Everything is explained here: https://github.com/naokazuterada/MarkdownTOC/releases,

default_depth is deprecated, use defaults.levels instead
lowercase_only_ascii is deprecated, use lowercase instead with new value format

@tajmone
Copy link

tajmone commented Mar 21, 2018

Thanks for the link @adoussot , after correcting the inline options everything works again.

I didn't get any Package-Update message for this MAJOR version update of MarkdownTOC, so it went by unnoticed.

@adoussot
Copy link
Author

adoussot commented Mar 21, 2018

Out of scope of this ISSUE: this is strange... my sublime didn't also show any upgrade message even if it should according to this Messaging documentation and the MarkdownTOC's messages.json file.

@naokazuterada
Copy link
Owner

naokazuterada commented Mar 22, 2018

@adoussot
Thanks for reporting, and sorry...
It looks like that sublime.load_settings doesn't merge recursively. I will check ASAP.

TEMPORALLY WORK AROUND
Copying and pasting whole Default Settings into your User Settings will works.
Also you should restart Sublime Text.

@naokazuterada naokazuterada added the bug Indicates an unexpected problem or unintended behavior label Mar 22, 2018
@adoussot
Copy link
Author

Don't apalogies. That's what reporting is made for :octocat:. Thanks for your work!

@naokazuterada
Copy link
Owner

@adoussot
I think the problem may fixed with 8cff52d. 3.0.1 will release soon.

I will close this issue but please inform me (maybe another issue) if 3.0.1 message didn't appear again in your environment. Of course, I will also watch carefully on my env. 👀

@tajmone
Copy link

tajmone commented Mar 24, 2018

After the 3.0.1 update it stopped working again. As mentioned before, I don't use custom settings, just inline settings in the comments.

I had already adjusted them to work with 3.0.0, and they were working fine, but now the TOC is not updated/created. I've checked all the settings key and values and they seem to conform with the doc specs:

<!-- MarkdownTOC autolink="true" bracket="round" autoanchor="false" lowercase="only_ascii" uri_encoding="true" levels="1,2,3" -->

@tajmone
Copy link

tajmone commented Mar 24, 2018

Very strange: if I create a User settings files with any setting, it works again.

It won't work unless a user settings file exists with at lease a valid setting. I've added:

{
  "logging": false
}

to my setting file.

Note: if the file is empty it won't work, nor if if the file contains just a comment line — it must contain some valid MarkdownTOC setting.

I've closed and reopned ST many times, just to make sure it wasn't a refresh problem of sorts, but not, the problem has to do with the presence of a custom settings file for MarkdownTOC.

@naokazuterada
Copy link
Owner

naokazuterada commented Mar 24, 2018

@tajmone Thanks for reporting.
I made a mistake again. Sorry...
I hope 3.0.2 fix your problem. (actually the version will be 2018.03.22.13.09.14 or something like that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants