diff --git a/TODOS.md b/TODOS.md index 8366e68..e5edb13 100644 --- a/TODOS.md +++ b/TODOS.md @@ -20,6 +20,7 @@ - [ ] Honestly, Test **all** diagnostics - [ ] Need to be careful about diagnostics across module boundaries. - we don't necessarily want to warn users about theme designers mistakes. (though perhaps we do) + - [ ] consider reporting duplicate weights outside of menus - [ ] Load grammars dynamically - [ ] starred must be a param. - [ ] Documentation @@ -32,6 +33,8 @@ - [ ] support JSON5 in in frontmatter - [ ] Create a json schema file for `thor.json`. - [ ] cleanup `#partial switch`es. +- [ ] improve json diagnostics. + - i.e. "Missing quotes around string", etc. ## Performance @@ -91,7 +94,9 @@ - [ ] Do we *need* mustache.Date_Components, or can we use core:time/datetime.DateTime? ## General -- [ ] configure opt-out of automatic sections being added to menu. +- [ ] Menus + - [ ] configure opt-out of automatic sections being added to menu. + - [ ] nested menus (i.e. `parent` support) - [ ] get rid of the global variables in the `treesitter` package. - [ ] Consider using `or_else` when applying default values to structs. i.e. ```odin diff --git a/menus.odin b/menus.odin index 5374e8f..4b19eea 100644 --- a/menus.odin +++ b/menus.odin @@ -262,6 +262,11 @@ compare_menu_entries :: proc(a, b: Menu_Entry) -> int { aw := a.weight.? or_else DEFAULT_WEIGHT bw := b.weight.? or_else DEFAULT_WEIGHT if aw != bw do return aw - bw + a_set := a.weight != nil + b_set := b.weight != nil + if a_set != b_set { + return a_set ? -1 : 1 + } return strings.compare(a.name, b.name) } @@ -284,7 +289,7 @@ warn_duplicate_weights :: proc(menu_name: string, entries: []Menu_Entry) { for i in 0 ..< len(entries) - 1 { if entries[i].weight != nil && entries[i].weight == entries[i + 1].weight { log.warnf( - "menus('%s'):'%s' and '%s' share the same weight (%d).", + "menus('%s'): '%s' and '%s' share the same menu weight (%d).", menu_name, entries[i].name, entries[i + 1].name, @@ -388,3 +393,4 @@ parse_config_menus :: proc( return result } +