@@ -111,6 +111,15 @@ actions.handle_hybrid_mode = function (linewise, buffer, line_count, wins, conte
111111 --- | fE
112112end
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
267276end
268277
278+ --- @return boolean uses_wrap Does the user use wrap support ?
269279actions .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 );
0 commit comments