Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Config settings not working. #386

Closed
izuzak opened this issue Feb 18, 2015 · 9 comments
Closed

Config settings not working. #386

izuzak opened this issue Feb 18, 2015 · 9 comments
Labels

Comments

@izuzak
Copy link
Contributor

izuzak commented Feb 18, 2015

From @JamesGould123 on February 18, 2015 4:13

In the docs, various examples of settings you can set for packages are documented. Unfortunately, several of the examples do not work.

The given array and object examples do not work. The array example simply does not show up under the settings under packages > package-name > settings, and the object example throws the error:

package-name.someSetting.myChildIntOption' could not set the default. Attempted default: undefined; Schema: {"type":"integer","minimum":1.5,"maximum":11.5}

I'm using version 0.177.0 of atom on Windows 7.

Copied from original issue: atom/atom#5604

@izuzak
Copy link
Contributor Author

izuzak commented Feb 18, 2015

@JamesGould123 I'm able to reproduce the problem with the array example -- I don't see anything in the settings when I use that either:

screen shot 2015-02-18 at 12 44 09

However, if I use this, I see the expected result:

config:
  someSetting:
    type: 'array'
    default: ["1", "2", "3"]

I'm unable to reproduce the problem with the object example though -- it doesn't throw an exception on Atom 0.180.0. Can you try reproducing on Atom 0.180.0 and let us know if it throws an exception? However, I don't see anything for that example in the settings view either. I do see something if I use something like this:

config:
  someSetting:
    type: 'object'
    properties:
      myChildIntOption:
        type: 'string'
        default: 'foo'

My guess is that this is a problem in the Settings View package, not in the examples. So I'm going to move this over to the Settings View package and cc @thedaniel and @benogle.

@JamesGould123
Copy link

@izuzak I've updated to 0.180 (for some reason my atom wouldn't update, thought I was on the latest version)

I'm still getting the error using the default object code from the documentation, it does go away if I add a default value to myChildIntOption, which would seem to be a mistake in the docs, as it seems the default field is simply required.

On the array issue, switching from an integer array to a string array fixes the problem, which again would seem to be a problem with the documentation.

@izuzak
Copy link
Contributor Author

izuzak commented Feb 18, 2015

I'm still getting the error using the default object code from the documentation

Can you provide the full contents of the file which contains that code? Perhaps in a gist? https://gist.github.com/

which again would seem to be a problem with the documentation.

That might be so, but it also might be a problem in the Settings View -- I would expect it to handle integer arrays as well. Let's see what the more knowledgeable folks say on this. Sound good?

@JamesGould123
Copy link

Yeah sure.

I'm on my work computer right now, so I've recreated the error in atom 0.180.0.
Steps:

  1. I used the default package manager's generate comand to create a package.
  2. I restarted atom, as the package failed to auto install. This may be another issue. Update: the issue underlying this appears to be documented here, and seems to be unrelated to this issue
  3. The package was successfully installed on restart.
  4. I opened the package, and added the following code to the top of module.exports in test-package.coffee, copied directly from the documentation.
  5.   config:
        someSetting:
          type: 'object'
          properties:
            myChildIntOption:
              type: 'integer'
              minimum: 1.5
              maximum: 11.5
    
  6. I removed the following lines from package.json to trigger automatic activation.
  7. "activationCommands": {
        "atom-workspace": "test-package:toggle"
      },
    
  8. I reloaded the window with ctrl-alt-r, and opened the console with ctrl-alt-i, and the message was there, right above the window load time. It is a warning message, like running console.warn in Chrome.

You can see all of the edited files here, on Gist

@Glavin001
Copy link
Contributor

I am experiencing this bug for Atom Beautify. Settings nested in an option of type object are disappearing. This occurs after I change/set any of the options. For instance, I start up Atom Beautify for the first time and it renders all options, those nested inside option of type object included. Then I change one (select/deselect checkbox, select an item from enum, etc) and then if I reload in the Settings panel those exact options I changed now do not appear!

I am now worried how long this will take 1) to fix on Settings-view and 2) to be published with Atom.
This issue is now a blocker for me. I am debating if I should opt to not using object type options at all, considering it forces all of my users to upgrade to the latest (next) Atom release (maybe their other packages cannot update, yet, so updating is not ideal) and also because I will have to wait for however long until Atom has this fixed and then released.
However, the object type options are very useful and should definitely be the way to go.

/cc Glavin001/atom-beautify#282

Update: I ended up opting to not using object type options. I hope to look into this later and contribute to resolving this bug in Atom to the best of my ability. It'd be great to use object type options in the future.

Glavin001 added a commit to Glavin001/atom-beautify that referenced this issue May 2, 2015
@ben-eb
Copy link

ben-eb commented Jul 26, 2015

+1, I'm also getting this.

@jeremyramin
Copy link
Contributor

+1 I am getting this as well.

A separate issue for this has been reported as well: #518.

jeremyramin added a commit to jeremyramin/atom that referenced this issue Aug 23, 2015
Previously, the get method would return only the top keys for objects in a config schema. Now with _.deepExtends, the defaultValues are the base while any new values overwrite the defaults. This way all default values, even nested ones, appear in the result of a call to atom.config.get(packageName). This fixes atom/settings-view#386 and fixes atom/settings-view#518.
jeremyramin added a commit to jeremyramin/atom that referenced this issue Aug 23, 2015
The config.get method would not return the default values for the
properties in objects. Now with _.deepExtends, the default values are
the base while any new values overwrite the defaults. This way all
default values appear, including those nested in an object. This fixes
atom/settings-view#386 and fixes atom/settings-vew#518.
@ben-eb
Copy link

ben-eb commented Aug 25, 2015

@jeremyramin Thanks! 👍

@VadimDor
Copy link

By me

`a_section:
  type: 'object'
  properties:
    prop1:
      title: 'a title'
      description: 'a description'
      type: 'array'
      default: [10,20]
      items:
        type: 'integer'`

shows nothing in config view, but the same with type: 'string' does!

Atom 1.19.3 x64 on Win 8.1

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

No branches or pull requests

6 participants