Skip to content

Overlay changes to config aren't applied #10592

@JoaquinTrinanes

Description

@JoaquinTrinanes

Describe the bug

I've got a nu module that (tries to) set the theme modifying the existing configuration. Specifically, it overrides the menu colors with custom ones.

When I use the module everything works fine, but overlay use'ing it doesn't have any effect.

How to reproduce

Create a module that modifies the config. I put together this MWE:

module theme {
    export-env {
        load-env {
            config: ($env.config 
            | upsert menus ($env.config.menus | each {|it| $it | upsert style {
                text: '#ffffff'
                description_text: '#0000ff'
                selected_text: '#ff0000'
              }}))
        }
    }
}

$env.config = {
    menus: [
        {
            name: completion_menu
            only_buffer_difference: false
            marker: "| "
            type: {
                layout: columnar
                columns: 4
                col_width: 20
                col_padding: 2
            }
            style: {}
        }
    ]
    keybindings: [
        {
            name: completion_menu
            modifier: none
            keycode: tab
            mode: [emacs vi_normal vi_insert]
            event: {
                until: [
                    { send: menu name: completion_menu }
                    { send: menunext }
                ]
            }
        }
    ]
}
  1. nu --config mwe.nu
  2. use theme
  3. The completion colors are changed

On the other hand:

  1. nu --config mwe.nu
  2. overlay use theme
  3. The completion colors are unchanged

$env.config.menus.0.style shows the expected values in both cases.

The obvious workaround for this is not using the module as an overlay of course 😁

Expected behavior

I expected using the module as an overlay to apply the same changes it would when it's used as-is.

Screenshots

image

Configuration

key value
version 0.85.1
branch main
commit_hash 80220b7
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.72.1 (d5c2e9c34 2023-09-13)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.72.1 (103a7ff2e 2023-08-15)
build_time 2023-09-28 14:24:50 +00:00
build_rust_channel release
allocator mimalloc
features dataframe, default, extra, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:configurationIssue related to nu's configurationA:modulesIssues related to functionality of the module system. See also usage:modulesA:parserIssues related to parsingA:scoping/name-resolutionHow Nu finds which variables/functions are in scope and to what they are boundcategory:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions