Skip to content

Commit c2bd780

Browse files
committed
fix(wrap): Do not override breakindent if wrap suppprt isn't used
1 parent 2af180a commit c2bd780

File tree

2 files changed

+19
-26
lines changed

2 files changed

+19
-26
lines changed

lua/markview/actions.lua

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ actions.handle_hybrid_mode = function (linewise, buffer, line_count, wins, conte
111111
---|fE
112112
end
113113

114+
actions.uses_wrap_support = function ()
115+
local spec = require("markview.spec");
116+
117+
return spec.get({ "markdown", "block_quotes", "wrap" }, { fallback = true }) or
118+
spec.get({ "markdown", "headings", "org_indent_wrap" }, { fallback = true }) or
119+
spec.get({ "markdown", "list_items", "wrap" }, { fallback = true })
120+
;
121+
end
122+
114123
---|fE
115124

116125
--- Wrapper to clear decorations from a buffer
@@ -266,6 +275,7 @@ actions.splitview_cursor = function ()
266275
---|fE
267276
end
268277

278+
---@return boolean uses_wrap Does the user use wrap support?
269279
actions.splitview_render = function ()
270280
---|fS
271281

@@ -632,9 +642,11 @@ actions.enable = function (buffer)
632642
This is to prevent `text wrap support` from being broken due to `breakindent` changing where wrapped text is shown.
633643
]]
634644

635-
for _, win in ipairs(vim.fn.win_findbuf(buffer)) do
636-
vim.w[win].__mkv_cached_breakindet = vim.wo[win].breakindent;
637-
vim.wo[win].breakindent = false;
645+
if actions.uses_wrap_support() then
646+
for _, win in ipairs(vim.fn.win_findbuf(buffer)) do
647+
vim.w[win].__mkv_cached_breakindet = vim.wo[win].breakindent;
648+
vim.wo[win].breakindent = false;
649+
end
638650
end
639651

640652
---|fE
@@ -685,8 +697,10 @@ actions.disable = function (buffer)
685697
We need to *restore* the original value of `breakindent` to respect user preference(we need to check if a cached value exists first).
686698
]]
687699

688-
for _, win in ipairs(vim.fn.win_findbuf(buffer)) do
689-
vim.wo[win].breakindent = vim.w[win].__mkv_cached_breakindet;
700+
if actions.uses_wrap_support() then
701+
for _, win in ipairs(vim.fn.win_findbuf(buffer)) do
702+
vim.wo[win].breakindent = vim.w[win].__mkv_cached_breakindet;
703+
end
690704
end
691705

692706
actions.clear(buffer);

lua/markview/wrap.lua

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -243,27 +243,6 @@ wrap.fine_wrap = function (buffer, win, row, ns, indent)
243243
);
244244
end
245245

246-
-- for vcol = win_width + 1, end_vcol, win_width do
247-
-- local wrapcol = vim.fn.virtcol2col(0, row + 1, vcol);
248-
--
249-
-- local indent_opts = {
250-
-- undo_restore = false, invalidate = true,
251-
-- right_gravity = true,
252-
--
253-
-- virt_text_pos = "inline",
254-
--
255-
-- virt_text = indent;
256-
-- };
257-
--
258-
-- vim.api.nvim_buf_set_extmark(
259-
-- buffer,
260-
-- ns,
261-
-- row,
262-
-- wrapcol - 1,
263-
-- indent_opts
264-
-- );
265-
-- end
266-
267246
---|fE
268247
end
269248

0 commit comments

Comments
 (0)