Skip to content

Commit

Permalink
fix: registering CSS theme via UI fails
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Sep 6, 2024
1 parent a2c3b64 commit 0a8c706
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,20 @@ protected void createButtons() {
final var themePath = Path.of(res);
final var themeFileName = themePath.getFileName().toString();
try {
final var rawTheme = RawThemeReader.readTheme(IThemeSource.fromFile(themePath));
final var rawThemeName = rawTheme.getName();
final String name = rawThemeName == null
? themeFileName.substring(0, themeFileName.lastIndexOf('.'))
: rawThemeName;
return new Theme(name, themePath.toAbsolutePath().toString(), name, false);
final String themeName;
if (themeFileName.endsWith(".css")) {
themeName = themeFileName.substring(0, themeFileName.lastIndexOf('.'));
} else {
final var rawTheme = RawThemeReader.readTheme(IThemeSource.fromFile(themePath));
final var rawThemeName = rawTheme.getName();
themeName = rawThemeName == null
? themeFileName.substring(0, themeFileName.lastIndexOf('.'))
: rawThemeName;
}
return new Theme(themeName, themePath.toAbsolutePath().toString(), themeName, false);
} catch (final Exception ex) {
MessageDialog.openError(getShell(), "Invalid theme file", "Failed to parse [" + themePath + "]: " + ex);
TMUIPlugin.logError(ex);
return null;
}

Expand Down

0 comments on commit 0a8c706

Please sign in to comment.