Skip to content

Commit a8a3ba6

Browse files
authored
Merge pull request #145 from FluxxField/fix/audit-cleanup
fix: audit cleanup - harden exit paths, rename config, add validation
2 parents ee8997f + fa14424 commit a8a3ba6

12 files changed

Lines changed: 51 additions & 17 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ SmartMotion wouldn't exist without these plugins. See [Why SmartMotion](https://
426426
{
427427
keys = "fjdksleirughtynm", -- label characters, home row first
428428
flow_state_timeout_ms = 300, -- chaining window, 0 to disable
429-
disable_dim_background = false, -- dim non-target text
429+
dim_background = true, -- dim non-target text
430430
auto_select_target = false, -- auto-jump on single target
431431
native_search = true, -- labels during / search
432432
count_behavior = "target", -- "target" or "native" for j/k counts

docs/Configuration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ Complete guide to configuring SmartMotion.
3232
-- Flow state timeout (ms): how long to stay in "flow" between motions
3333
flow_state_timeout_ms = 300,
3434

35-
-- Disable dimming of non-target text
36-
disable_dim_background = false,
35+
-- Dim non-target text for better label visibility
36+
dim_background = true,
3737

3838
-- Maximum motions stored in repeat history
3939
history_max_size = 20,
@@ -344,8 +344,8 @@ count_behavior = "native"
344344
Dim non-target text for better label visibility:
345345

346346
```lua
347-
disable_dim_background = false -- dimming enabled (default)
348-
disable_dim_background = true -- dimming disabled
347+
dim_background = true -- dimming enabled (default)
348+
dim_background = false -- dimming disabled
349349
```
350350

351351
---

docs/Debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ require("smart-motion").setup({
236236
two_char_hint = { fg = "#000000", bg = "#00FF00", bold = true },
237237
dim = { fg = "#333333" },
238238
},
239-
disable_dim_background = false,
239+
dim_background = true,
240240
})
241241
```
242242

docs/Quick-Start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ opts = {
178178
native_search = true,
179179

180180
-- Dim non-target text
181-
disable_dim_background = false,
181+
dim_background = true,
182182

183183
-- Open folds at target position after jumping
184184
open_folds_on_jump = true,

lua/smart-motion/config.lua

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ M.defaults = {
2525
highlight = default_highlight_groups,
2626
presets = {},
2727
flow_state_timeout_ms = FLOW_STATE_TIMEOUT_MS,
28-
disable_dim_background = false,
28+
dim_background = true,
2929
history_max_size = HISTORY_MAX_SIZE,
3030
auto_select_target = false,
3131
native_search = true,
@@ -141,10 +141,17 @@ function M.validate(user_config)
141141
end
142142

143143
--
144-
-- Validate disable_dim_background
144+
-- Validate dim_background (supports deprecated disable_dim_background)
145145
--
146-
if config.disable_dim_background == nil or type(config.disable_dim_background) ~= "boolean" then
147-
config.disable_dim_background = false
146+
if config.disable_dim_background ~= nil then
147+
log.warn("'disable_dim_background' is deprecated, use 'dim_background' instead")
148+
if config.dim_background == nil or config.dim_background == M.defaults.dim_background then
149+
config.dim_background = not config.disable_dim_background
150+
end
151+
config.disable_dim_background = nil
152+
end
153+
if config.dim_background == nil or type(config.dim_background) ~= "boolean" then
154+
config.dim_background = true
148155
end
149156

150157
--
@@ -161,6 +168,13 @@ function M.validate(user_config)
161168
config.auto_select_target = false
162169
end
163170

171+
--
172+
-- Validate native_search
173+
--
174+
if config.native_search == nil or type(config.native_search) ~= "boolean" then
175+
config.native_search = true
176+
end
177+
164178
--
165179
-- Validate count_behavior
166180
--

lua/smart-motion/core/engine/exit.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ function M.run(ctx, cfg, motion_state, exit_type)
2020
-- Re-rendering here would use the full (unfiltered) key pool, which produces
2121
-- different label assignments than the conflict-filtered labels the user already saw.
2222
if vim.tbl_isempty(motion_state.assigned_hint_labels) then
23+
if not modules.visualizer or not modules.visualizer.run then
24+
return
25+
end
2326
modules.visualizer.run(ctx, cfg, motion_state)
2427
end
2528
selection.wait_for_hint_selection(ctx, cfg, motion_state)
@@ -28,7 +31,7 @@ function M.run(ctx, cfg, motion_state, exit_type)
2831
if motion_state.selected_jump_target then
2932
if ctx.mode and ctx.mode:find("o") and not motion_state.is_textobject then
3033
require("smart-motion.actions.jump").run(ctx, cfg, motion_state)
31-
else
34+
elseif modules.action and modules.action.run then
3235
modules.action.run(ctx, cfg, motion_state)
3336
end
3437
end

lua/smart-motion/core/engine/loop.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function M.run(ctx, cfg, motion_state)
3737
exit_event.throw(EXIT_TYPE.CONTINUE_TO_SELECTION)
3838
end
3939

40-
-- Mulit-pass mode
40+
-- Multi-pass mode
4141
if motion_state.is_searching_mode then
4242
while true do
4343
local start_time = vim.fn.reltime()

lua/smart-motion/core/engine/pipeline.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function M.run(ctx, cfg, motion_state)
8080
exit.throw_if(not modifier_generator, EXIT_TYPE.EARLY_EXIT)
8181

8282
local filter_generator = modules.filter.run(modifier_generator)
83-
exit.throw_if(not filter_generator)
83+
exit.throw_if(not filter_generator, EXIT_TYPE.EARLY_EXIT)
8484

8585
targets.get_targets(ctx, cfg, motion_state, filter_generator)
8686
state.finalize_motion_state(ctx, cfg, motion_state)

lua/smart-motion/core/highlight.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ end
167167
---@param cfg SmartMotionConfig
168168
---@param motion_state SmartMotionMotionState
169169
function M.dim_background(ctx, cfg, motion_state)
170-
-- NOTE: Rename config to dim_background
171-
if cfg.disable_dim_background ~= false or motion_state.dim_background == false then
170+
if not cfg.dim_background or motion_state.dim_background == false then
172171
return
173172
end
174173

lua/smart-motion/types.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
---@field highlight table<string, string | table>
2020
---@field presets SmartMotionPresets
2121
---@field flow_state_timeout_ms number
22-
---@field disable_dim_background boolean
22+
---@field dim_background boolean
2323
---@field native_search? boolean
2424
---@field count_behavior? "target" | "native"
2525
---@field open_folds_on_jump? boolean

0 commit comments

Comments
 (0)