rstudio / thematic

Theme ggplot2, lattice, and base graphics based on a few simple settings.
https://rstudio.github.io/thematic/
Other
244 stars 10 forks source link

Be resilient to `getThemeInfo()` not being available or not working as expected #138

Closed gadenbuie closed 1 year ago

gadenbuie commented 1 year ago

This PR adds a specific test for the availability of the rstudioapi::getThemeInfo() function before checking for the IDE theme colors.

There are scenarios where rstudioapi::isAvailable() will return TRUE, but getThemeInfo() isn't available. In those cases, rs_theme_colors() will error and thematic will fail ungracefully.

This PR adds a check using rstudioapi::findFun("getThemeInfo") and then for extra safety wraps the whole thing in a tryCatch() in a new try_get_theme_info() helper function.