Fix a regression in the previous release that broke usage of custom themes

Fixes #6191
This commit is contained in:
Kovid Goyal 2023-04-17 08:45:46 +05:30
parent b966013a2b
commit a09464dee9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 15 additions and 5 deletions

View File

@ -42,6 +42,8 @@ Detailed list of changes
- Fix a regression in the previous release that broke handling of some key board shortcuts in some kittens on some keyboard layouts (:iss:`6189`)
- Fix a regression in the previous release that broke usage of custom themes (:iss:`6191`)
0.28.0 [2023-04-15]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -532,10 +532,11 @@ func parse_theme_metadata(path string) (*ThemeMetadata, map[string]string, error
type Theme struct {
metadata *ThemeMetadata
code string
settings map[string]string
zip_reader *zip.File
is_user_defined bool
code string
settings map[string]string
zip_reader *zip.File
is_user_defined bool
path_for_user_defined_theme string
}
func (self *Theme) Name() string { return self.metadata.Name }
@ -558,6 +559,13 @@ func (self *Theme) load_code() (string, error) {
}
self.code = utils.UnsafeBytesToString(data)
}
if self.is_user_defined && self.path_for_user_defined_theme != "" && self.code == "" {
raw, err := os.ReadFile(self.path_for_user_defined_theme)
if err != nil {
return "", err
}
self.code = utils.UnsafeBytesToString(raw)
}
return self.code, nil
}
@ -813,7 +821,7 @@ func (self *Themes) AddFromFile(path string) (*Theme, error) {
if m.Name == "" {
m.Name = theme_name_from_file_name(filepath.Base(path))
}
t := Theme{metadata: m, is_user_defined: true, settings: conf}
t := Theme{metadata: m, is_user_defined: true, settings: conf, path_for_user_defined_theme: path}
self.name_map[m.Name] = &t
return &t, nil