Skip to content

Commit 4947fce

Browse files
committed
fix(compiler): consider entire config when hashing
Related: projekt0n#262, projekt0n#340, projekt0n#341
1 parent c8c1e09 commit 4947fce

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Closed #305 (no longer valid, fixed)
2626
- Closed #292 (no longer valid, fixed)
2727
- fix(config): `options.darken.floats` is not used (#345)
28+
- fix(compiler): consider entire config when hashing (#350) (related to #262, #340, #341)
2829

2930
## [v1.0.2] - 03 May 2023
3031

lua/github-theme/init.lua

+20-14
Original file line numberDiff line numberDiff line change
@@ -72,38 +72,44 @@ function M.load(opts)
7272
end
7373

7474
M.setup = function(opts)
75+
local override = require('github-theme.override')
76+
local keys = { 'palettes', 'specs', 'groups' }
7577
did_setup = true
7678
opts = opts or {}
7779

78-
local override = require('github-theme.override')
79-
8080
-- New configs
8181
if opts.options then
8282
config.set_options(opts.options)
8383
end
8484

85-
if opts.palettes ~= nil then
86-
override.palettes = opts.palettes
87-
end
88-
89-
if opts.specs ~= nil then
90-
override.specs = opts.specs
91-
end
92-
93-
if opts.groups ~= nil then
94-
override.groups = opts.groups
85+
for _, k in ipairs(keys) do
86+
local v = opts[k]
87+
if v ~= nil then
88+
override[k] = v
89+
end
9590
end
9691

9792
local util = require('github-theme.util')
9893
util.ensure_dir(config.options.compile_path)
9994

10095
local cached_path = util.join_paths(config.options.compile_path, 'cache')
10196
local cached = read_file(cached_path)
102-
10397
local git_path =
10498
vim.fn.fnamemodify(vim.fn.resolve(debug.getinfo(1).source:sub(2)), ':p:h:h:h')
10599
local git = vim.fn.getftime(util.join_paths(git_path, '.git'))
106-
local hash = require('github-theme.lib.hash')(opts) .. (git == -1 and git_path or git)
100+
101+
-- This is needed because neither `opts` nor `config` necessarily contain
102+
-- everything we need to hash. For example, `opts` may not contain all
103+
-- overrides and config currently in use (`setup()` might have been called
104+
-- before, or maybe overrides were set directly and outside of `setup()`), and
105+
-- `config` does not contain any of the overrides in use. Therefore, we need
106+
-- to create a new table which contains everything in-use.
107+
local dummy = { options = config.options }
108+
for _, k in ipairs(keys) do
109+
dummy[k] = override[k]
110+
end
111+
112+
local hash = require('github-theme.lib.hash')(dummy) .. (git == -1 and git_path or git)
107113

108114
if cached ~= hash then
109115
M.compile()

lua/github-theme/override.lua

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local collect = require('github-theme.lib.collect')
21
local M = {}
32

43
function M.reset()

0 commit comments

Comments
 (0)