fix: fixed issues the @janitor found

This commit is contained in:
Hayden Hargreaves 2026-04-08 17:28:01 -07:00
parent 64c448c639
commit e27c7560a2
5 changed files with 5 additions and 35 deletions

View File

@ -51,7 +51,6 @@ type Model struct {
registers map[rune]core.Register // name -> register
// Visual styles
// currentTheme string // Name of current theme
themes map[string]theme.EditorTheme
syntax syntax.Engine
@ -186,7 +185,7 @@ func (m *Model) replayInsert() {
}
}
// TODO: Fix this shitty shit shit shit
// TODO: This can't be the best way....
func (m *Model) processInsertKey(key string) {
win := m.ActiveWindow()
buf := m.ActiveBuffer()

View File

@ -20,7 +20,7 @@ func NewModelBuilder() *ModelBuilder {
var embededThemes map[string]theme.EditorTheme
embededThemesJson, err := theme.LoadEmbeddedThemesJSON()
if err == nil {
embededThemes = theme.MapEmbededThemeToEditorTheme(embededThemesJson)
embededThemes = theme.MapEmbeddedThemeToEditorTheme(embededThemesJson)
}
// Always have a default theme

View File

@ -2,6 +2,7 @@ package syntax
import (
"fmt"
"maps"
"strings"
"testing"
@ -361,9 +362,7 @@ func makeThemeWithCaptureOverrides(lineFg, keywordFg, stringFg lipgloss.Color) t
func cloneStyleMap(in map[string]lipgloss.Style) map[string]lipgloss.Style {
out := make(map[string]lipgloss.Style, len(in))
for k, v := range in {
out[k] = v
}
maps.Copy(out, in)
return out
}

View File

@ -46,7 +46,7 @@ func LoadEmbeddedThemesJSON() (map[string]ThemeJSON, error) {
return out, nil
}
func MapEmbededThemeToEditorTheme(em map[string]ThemeJSON) map[string]EditorTheme {
func MapEmbeddedThemeToEditorTheme(em map[string]ThemeJSON) map[string]EditorTheme {
out := make(map[string]EditorTheme, len(em))
for name, in := range em {
@ -111,12 +111,6 @@ func MapEmbededThemeToEditorTheme(em map[string]ThemeJSON) map[string]EditorThem
return out
}
// MapEmbeddedThemeToEditorTheme is a correctly spelled alias for
// MapEmbededThemeToEditorTheme.
func MapEmbeddedThemeToEditorTheme(em map[string]ThemeJSON) map[string]EditorTheme {
return MapEmbededThemeToEditorTheme(em)
}
func styleFromJSON(in ColorStyleJSON) lipgloss.Style {
out := lipgloss.NewStyle()

View File

@ -90,28 +90,6 @@ func TestMapEmbeddedThemeToEditorTheme_MapsStylesAndNormalizesSyntaxKeys(t *test
}
}
func TestMapEmbededThemeToEditorTheme_AliasMatchesPrimary(t *testing.T) {
in := map[string]ThemeJSON{
"x": {
Name: "x",
Line: ColorStyleJSON{FG: "#ffffff", BG: "#000000"},
Syntax: SyntaxJSON{
Group: map[string]string{"keyword": "#123456"},
},
},
}
a := MapEmbededThemeToEditorTheme(in)
b := MapEmbeddedThemeToEditorTheme(in)
if len(a) != len(b) {
t.Fatalf("alias map size mismatch: %d vs %d", len(a), len(b))
}
if colorHex(a["x"].Syntax.Group["keyword"].GetForeground()) != colorHex(b["x"].Syntax.Group["keyword"].GetForeground()) {
t.Fatalf("alias should produce identical mapped styles")
}
}
func colorHex(c any) string {
return fmt.Sprint(c)
}