Update `detectindent` cache only after saving/reloading
Before, if the indent wasn't fully detected, `detectindent` would try to update every second. On files with very long lines this would cause stutters. Now the indent is updated only once after saving/reloading.
This commit is contained in:
parent
df667ad28e
commit
e99c76f8b8
|
@ -114,8 +114,11 @@ function Doc:new(...)
|
||||||
if not cache[self].confirmed then
|
if not cache[self].confirmed then
|
||||||
core.add_thread(function ()
|
core.add_thread(function ()
|
||||||
while not cache[self].confirmed do
|
while not cache[self].confirmed do
|
||||||
|
if cache[self].need_update then
|
||||||
update_cache(self)
|
update_cache(self)
|
||||||
coroutine.yield(1)
|
cache[self].need_update = false
|
||||||
|
end
|
||||||
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
end, self)
|
end, self)
|
||||||
end
|
end
|
||||||
|
@ -124,7 +127,7 @@ end
|
||||||
local clean = Doc.clean
|
local clean = Doc.clean
|
||||||
function Doc:clean(...)
|
function Doc:clean(...)
|
||||||
clean(self, ...)
|
clean(self, ...)
|
||||||
update_cache(self)
|
cache[self].need_update = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue