diff --git a/visidata/textsheet.py b/visidata/textsheet.py index 4a4f3f09a..c2d07b664 100644 --- a/visidata/textsheet.py +++ b/visidata/textsheet.py @@ -83,6 +83,9 @@ def sysopen_error(self, col, row): vd.launchEditor(match.group(1), f'+{match.group(2)}') return + def reload(self): + src = self.source or (vd.lastErrors and vd.lastErrors[-1]) + self.rows = list(enumerate(src)) class ErrorCellSheet(ErrorSheet): columns = [ @@ -102,23 +105,22 @@ class ErrorsSheet(Sheet): ColumnItem('lastline', -1) ] def reload(self): - self.rows = self.source + self.rows = self.source or vd.lastErrors def openRow(self, row): return ErrorSheet(source=self.cursorRow) -@VisiData.property +@VisiData.lazy_property def allErrorsSheet(self): - return ErrorsSheet("errors_all", source=vd.lastErrors) + return ErrorsSheet("errors_all") -@VisiData.property +@VisiData.lazy_property def recentErrorsSheet(self): - error = vd.lastErrors[-1] if vd.lastErrors else '' - return ErrorSheet("errors_recent", source=error) + return ErrorSheet("errors_recent") -BaseSheet.addCommand('^E', 'error-recent', 'vd.push(recentErrorsSheet) if vd.lastErrors else status("no error")', 'view traceback for most recent error') +BaseSheet.addCommand('^E', 'error-recent', 'recentErrorsSheet.reload(); vd.push(recentErrorsSheet) if vd.lastErrors else status("no error")', 'view traceback for most recent error') BaseSheet.addCommand('g^E', 'errors-all', 'vd.push(vd.allErrorsSheet)', 'view traceback for most recent errors') Sheet.addCommand('z^E', 'error-cell', 'vd.push(ErrorCellSheet(sheet.name+"_cell_error", sourceSheet=sheet, source=getattr(cursorCell, "error", None) or fail("no error this cell")))', 'view traceback for error in current cell')