Skip to content

Commit

Permalink
fix: preserve column ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-abrioux committed Nov 12, 2024
1 parent 465737b commit cb51401
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ markdown-table-formatter = "0.3.0"
serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
serde_yml = "0.0.12"
indexmap = { version = "2.6.0", features = ["serde"] }

[dev-dependencies]
assert_cmd = "2.0.16"
Expand Down
18 changes: 18 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,22 @@ tools:
"##;
generate_toolbox(&input.to_string());
}

#[test]
fn should_not_sort_columns_alphabetically() {
let input = "
tools:
z:
- neovim
a:
- javascript";
let markdown = generate_toolbox(&input.to_string());
assert_eq!(
markdown,
r#"| z | a |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| [<img align="left" alt="Neovim" src="https://img.shields.io/badge/-Neovim-57A143?logoColor=white&logo=neovim">](#) | [<img align="left" alt="JavaScript" src="https://img.shields.io/badge/-JavaScript-F7DF1E?logoColor=black&logo=javascript">](#) |
"#
);
}
}
4 changes: 2 additions & 2 deletions src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use indexmap::IndexMap;
use serde::Deserialize;
use std::collections::BTreeMap;

#[derive(Deserialize, Debug, PartialEq)]
pub struct Config {
pub tools: Tools,
}

pub type Tools = BTreeMap<String, Vec<ToolEnum>>;
pub type Tools = IndexMap<String, Vec<ToolEnum>>;

#[derive(Deserialize, Debug, PartialEq)]
#[serde(untagged)]
Expand Down

0 comments on commit cb51401

Please sign in to comment.