We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 12da42e commit b6907d5Copy full SHA for b6907d5
lua/orgmode/org/format.lua
@@ -45,6 +45,17 @@ local function format()
45
return 1
46
end
47
48
+ -- When closed folds are being formatted, fallback formatting can
49
+ -- happen with multiple lines instead of a single line due to some side effects.
50
+ -- When we encounter that we need to return 0 to avoid infinite loop.
51
+ -- This will prevent some of the lines of being formatted correctly,
52
+ -- but there's no way to exit the infinite loop otherwise.
53
+ for linenr = start_line, end_line do
54
+ if formatexpr_cache[linenr] and vim.fn.foldclosed(linenr) > -1 then
55
+ return 0
56
+ end
57
58
+
59
for linenr = start_line, end_line do
60
local line_formatted = format_line(linenr)
61
if not line_formatted then
0 commit comments