Skip to content

Commit d0cbd1f

Browse files
committed
fix(stage): enable using non-horizontal layout strategy
1 parent ce80fa1 commit d0cbd1f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lua/tinygit/config.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,24 @@ function M.setup(userConfig)
136136
local msg = ('Border type "none" is not supported, falling back to %q.'):format(fallback)
137137
require("tinygit.shared.utils").notify(msg, "warn")
138138
end
139+
140+
-- VALIDATE `context` > 0 (0 is not supported without `--unidiff-zero`)
141+
-- DOCS https://git-scm.com/docs/git-apply#Documentation/git-apply.txt---unidiff-zero
142+
-- However, it is discouraged in the git manual, and `git apply` tends to
143+
-- fail quite often, probably as line count changes are not accounted for
144+
-- when splitting up changes into hunks in `getHunksFromDiffOutput`.
145+
-- Using context=1 works, but has the downside of not being 1:1 the same
146+
-- hunks as with `gitsigns.nvim`. Since many small hunks are actually abit
147+
-- cumbersome, and since it's discouraged by git anyway, we simply disallow
148+
-- context=0 for now.
149+
if M.config.stage.contextSize < 1 then M.config.stage.contextSize = 1 end
150+
151+
-- `preview_width` is only supported by `horizontal` & `cursor` strategies,
152+
-- see https://github.com/chrisgrieser/nvim-scissors/issues/28
153+
local strategy = M.config.stage.telescopeOpts.layout_strategy
154+
if strategy ~= "horizontal" and strategy ~= "cursor" then
155+
M.config.stage.telescopeOpts.layout_config.preview_width = nil
156+
end
139157
end
140158

141159
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)