Commit 4391221d authored by Kai Willadsen's avatar Kai Willadsen

filediff: Fix bug with very many opcodes being cycled through the cache

In some situations where we, for example, did a replace all that caused
many inline highlighting requests to pile through the cache, it was
possible that between checking that we had the cached opcodes and
actually returning those opcodes in the mainloop, the opcodes would be
evicted from the cache. With this change, we keep an in-scope copy of
the cached opcodes around so that this won't happen.
parent a8f1223b
......@@ -78,10 +78,11 @@ class CachedSequenceMatcher(object):
def match(self, text1, textn, cb):
try:
self.cache[(text1, textn)][1] = time.time()
opcodes = self.cache[(text1, textn)][0]
# FIXME: This idle should be totally unnecessary, and yet nothing
# gets highlighted without it, even though everything in the
# callback appears to run identically.
GLib.idle_add(lambda: cb(self.cache[(text1, textn)][0]))
GLib.idle_add(lambda: cb(opcodes))
except KeyError:
def inline_cb(opcodes):
self.cache[(text1, textn)] = [opcodes, time.time()]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment