Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[errors-] create Error(s)Sheet only if it is not already open #2671

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions visidata/textsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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')
Expand Down
Loading