Skip to content
New issue

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

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

Already on GitHub? # to your account

LayerSet.rename_layer does not set new path #253

Closed
madig opened this issue Jan 21, 2022 · 2 comments · Fixed by #254
Closed

LayerSet.rename_layer does not set new path #253

madig opened this issue Jan 21, 2022 · 2 comments · Fixed by #254

Comments

@madig
Copy link
Collaborator

madig commented Jan 21, 2022

A new path should be generated when renaming layers, just like for glyphs.

@cmyr
Copy link
Member

cmyr commented Jan 21, 2022

yep, sounds like a bug to me.

@madig
Copy link
Collaborator Author

madig commented Jan 24, 2022

Test cases:

    #[test]
    fn rename_layer() {
        let mut layer_set = LayerSet::default();

        // Non-default layers can be renamed and get a new path.
        layer_set.new_layer("aaa").unwrap();
        assert_eq!(layer_set.get("aaa").unwrap().path().as_os_str(), "glyphs.aaa");

        layer_set.rename_layer("aaa", "bbb", false).unwrap();
        assert_eq!(layer_set.get("bbb").unwrap().path().as_os_str(), "glyphs.bbb");
    }

    #[test]
    fn rename_default_layer() {
        let mut layer_set = LayerSet::default();

        // The default layer can be renamed but the path stays the same.
        layer_set.rename_layer("public.default", "aaa", false).unwrap();

        assert_eq!(*layer_set.default_layer().name(), "aaa");
        assert_eq!(layer_set.default_layer().path().as_os_str(), "glyphs");
    }

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

Successfully merging a pull request may close this issue.

2 participants