Use IndexMap for a deterministic order when importing syntax colors

This commit is contained in:
Marshall Bowers 2023-11-09 13:12:36 -05:00
parent 1f0fccc353
commit 978cff8095
15 changed files with 143 additions and 143 deletions

View file

@ -10,6 +10,7 @@ publish = false
anyhow.workspace = true
convert_case = "0.6.0"
gpui = { package = "gpui2", path = "../gpui2" }
indexmap = "1.6.2"
log.workspace = true
rust-embed.workspace = true
serde.workspace = true

View file

@ -1,7 +1,6 @@
use std::collections::HashMap;
use anyhow::Result;
use gpui::{Hsla, Rgba};
use indexmap::IndexMap;
use theme::{
StatusColorsRefinement, ThemeColorsRefinement, UserSyntaxTheme, UserTheme,
UserThemeStylesRefinement,
@ -34,7 +33,7 @@ impl VsCodeThemeConverter {
let status_color_refinements = self.convert_status_colors()?;
let theme_colors_refinements = self.convert_theme_colors()?;
let mut highlight_styles = HashMap::new();
let mut highlight_styles = IndexMap::new();
for token_color in self.theme.token_colors {
highlight_styles.extend(token_color.highlight_styles()?);

View file

@ -2,9 +2,8 @@
// Map tokenColors style to HighlightStyle (fontStyle, foreground, background)
// Take in the scopes from the tokenColors and try to match each to our HighlightStyles
use std::collections::HashMap;
use anyhow::Result;
use indexmap::IndexMap;
use serde::Deserialize;
use theme::UserHighlightStyle;
@ -33,13 +32,13 @@ pub struct VsCodeTokenColorSettings {
}
impl VsCodeTokenColor {
pub fn highlight_styles(&self) -> Result<HashMap<String, UserHighlightStyle>> {
let mut highlight_styles = HashMap::new();
pub fn highlight_styles(&self) -> Result<IndexMap<String, UserHighlightStyle>> {
let mut highlight_styles = IndexMap::new();
let scope = match self.scope {
Some(VsCodeTokenScope::One(ref scope)) => vec![scope.clone()],
Some(VsCodeTokenScope::Many(ref scopes)) => scopes.clone(),
None => return Ok(HashMap::new()),
None => return Ok(IndexMap::new()),
};
for scope in &scope {