fix(linja): incorrect output when maximum number of errors/warnings was reached, fixes #352

This commit is contained in:
Leonardo de Moura 2014-11-28 15:21:56 -08:00
parent 9516cd9ee3
commit 3adf5ce1e1

View file

@ -104,6 +104,8 @@ class FlycheckItemList:
self.items = filter(pred, self.items)
def append(self, item):
self.items.append(item)
def truncate(self, n):
del self.items[n:]
def removeExtraItemsStartswith(self, text):
self.sort()
newItems = self.items[:1]
@ -407,7 +409,7 @@ def process_lean_output(target, out, args):
# Add tooManyItemsError at the end if we truncated the list
if n and len(flycheckItemList) > n:
count = len(flycheckItemList)
flycheckItemList = flycheckItemList[:n]
flycheckItemList.truncate(n)
tooManyItemsError = FlycheckItem(target, 1, 0, "error", "For performance, we only display %d errors/warnings out of %d. (lean-flycheck-max-messages-to-display)" % (n, count))
flycheckItemList.append(tooManyItemsError)
print flycheckItemList