Skip to content

feat: ignore whitespace option (diffopt+=iwhite support)#235

Merged
esmuellert merged 2 commits intomainfrom
dev
Feb 10, 2026
Merged

feat: ignore whitespace option (diffopt+=iwhite support)#235
esmuellert merged 2 commits intomainfrom
dev

Conversation

@esmuellert
Copy link
Owner

Summary

Wire the existing ignore_trim_whitespace option from the VSCode diff C library through to the user-facing config, enabling users to suppress whitespace-only changes in diffs.

Changes

  • config.lua: Add diff.ignore_trim_whitespace option (default: false)
  • render.lua: Pass option in both compute_and_render and compute_and_render_conflict
  • auto_refresh.lua: Pass option in both regular and result-buffer diff paths
  • state.lua: Pass option (previously called compute_diff with no options at all)
  • README.md: Document the new option
  • tests/ignore_whitespace_spec.lua: 6 test cases validating FFI behavior

Usage

require('codediff').setup({
  diff = {
    ignore_trim_whitespace = true,
  },
})

Benefits

  • Declutters diffs where indentation style changed but content is the same
  • Equivalent to Vim's diffopt+=iwhite
  • Zero overhead — the C library already supported it, this just wires it through

Closes #232

Expose the existing VSCode diff algorithm's ignore_trim_whitespace
option via config (diff.ignore_trim_whitespace). This allows users
to suppress whitespace-only changes in diffs, similar to diffopt+=iwhite.

- Add ignore_trim_whitespace config option (default: false)
- Pass option through render.lua, auto_refresh.lua, and state.lua
- Add tests for the ignore_trim_whitespace FFI option
- Update README with new option

Closes #232
@esmuellert esmuellert enabled auto-merge February 10, 2026 06:40
@esmuellert esmuellert merged commit 26058b0 into main Feb 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore whitespaces.

1 participant