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

[BUG] Custom configuration is ignored and overridden #16

Closed
Glavin001 opened this issue Jun 13, 2014 · 5 comments
Closed

[BUG] Custom configuration is ignored and overridden #16

Glavin001 opened this issue Jun 13, 2014 · 5 comments

Comments

@Glavin001
Copy link
Owner

image

Notice that in the first log, under html the indent_size is 6. However, later on it is overridden to indent_size: 6.

@Glavin001 Glavin001 changed the title Custom configuration is ignored and overridden [BUG] Custom configuration is ignored and overridden Jun 13, 2014
@Glavin001 Glavin001 mentioned this issue Jun 13, 2014
5 tasks
@Glavin001
Copy link
Owner Author

Just got it working:

image

In the example above, it is for HTML.

@Glavin001
Copy link
Owner Author

Removed https://github.com/donaldpipowitch/atom-beautify/blob/45352dd90591826e72054536f671b9eb074a9843/lib/atom-beautify.js#L154-L156 because it was incorrectly merging all of the options together.

for (key in externalOptions) {
      _.merge(collectedConfig, externalOptions[key]);
}

Important: This will result in previous usage of nested configurations no longer merging, such as using the indent_size of js when applying to a HTML file.

@Glavin001
Copy link
Owner Author

I just noticed that the indent_char is being overridden to "" (empty string).

image

You can even see it in the screenshot in previous comments, final options versus the getOptions result in the console log.


The afflicting code is the cleanOptions:

function cleanOptions(data, types) {
  nopt.clean(data, types);
  return data;
}

Which really just calls https://github.com/npm/nopt

@Glavin001
Copy link
Owner Author

I am going to temporarily comment out the lines that use nopt, as it is definitely the issue.

Currently working on Handlebars support (see #13) and commenting it out makes everything work:

Before:

{{#if}}
{{#each}}
{{#if}}
content
{{/if}}
{{#if}}
content
{{/if}}
{{/each}}
{{/if}}

After (with nopt disabled):

{{#if}}
  {{#each}}
    {{#if}}
      content
    {{/if}}
    {{#if}}
      content
    {{/if}}
  {{/each}}
{{/if}}

@Glavin001
Copy link
Owner Author

See npm/nopt#38 (comment)

I have an object like the following:

{
  'indent_char': ' '
}

Where indent_char is a space character (' ').
After using nopt to clean, it is now an empty string, ''.
The same error occurs when using tab, '\t'.
Using underscore, '_', works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant