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

[mouse-] click on error note to run error-cell #2381

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion visidata/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def getCell(self, row):
dispval = options.disp_error_val
return DisplayWrapper(cellval.val, error=exc.stacktrace,
text=dispval,
note=options.disp_note_getexc,
note=f'[:onclick error-cell]{options.disp_note_getexc}[:]',
notecolor='color_error')
elif typedval.val is None: # early out for strict None
return DisplayWrapper(None, text='', # force empty display for None
Expand Down
2 changes: 2 additions & 0 deletions visidata/pyobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ def launch_repl(v, i):
BaseSheet.addCommand('', 'assert-expr', 'expr=inputPythonExpr(); assert sheet.evalExpr(expr), f"{expr} not true"', 'eval Python expression and assert result is truthy')
BaseSheet.addCommand('', 'assert-expr-row', 'expr=inputPythonExpr(); assert sheet.evalExpr(expr, row=cursorRow), f"{expr} not true"', 'eval Python expression in context of current row, and assert result is truthy')

Sheet.addCommand(None, 'view-cell', 'vd.push(openCellPyobj(cursorCol, cursorRowIndex))', 'view contents of current cell in a new sheet')

Sheet.addCommand('^Y', 'pyobj-row', 'status(type(cursorRow).__name__); vd.push(openRowPyobj(cursorRowIndex))', 'open current row as Python object')
Sheet.addCommand('z^Y', 'pyobj-cell', 'status(type(cursorValue).__name__); vd.push(openCellPyobj(cursorCol, cursorRowIndex))', 'open current cell as Python object')
BaseSheet.addCommand('g^Y', 'pyobj-sheet', 'status(type(sheet).__name__); vd.push(PyobjSheet(sheet.name+"_sheet", source=sheet))', 'open current sheet as Python object')
Expand Down
20 changes: 17 additions & 3 deletions visidata/textsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,23 @@ def writelines(sheet, fn):
# .source is list of source text lines to 'load'
# .sourceSheet is Sheet error came from
class ErrorSheet(TextSheet):
columns = [
ColumnItem('linenum', 0, type=int, width=0),
ColumnItem('error', 1),
]
guide = '''# Error Sheet'''
precious = False

class ErrorCellSheet(ErrorSheet):
columns = [
ColumnItem('linenum', 0, type=int, width=0),
ColumnItem('cell_error', 1),
]
guide = '''# Error Cell Sheet
This sheet shows the error that occurred when calculating a cell.
- `q` to quit this error sheet.
'''


class ErrorsSheet(Sheet):
columns = [
Expand All @@ -83,15 +98,14 @@ def recentErrorsSheet(self):
BaseSheet.addCommand('^E', 'error-recent', 'vd.lastErrors and vd.push(recentErrorsSheet) or 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(None, 'view-cell', 'vd.push(ErrorSheet("%s[%s].%s" % (name, cursorRowIndex, cursorCol.name), sourceSheet=sheet, source=cursorDisplay.splitlines()))', 'view contents of current cell in a new sheet')
Sheet.addCommand('z^E', 'error-cell', 'vd.push(ErrorSheet(sheet.name+"_cell_error", sourceSheet=sheet, source=getattr(cursorCell, "error", None) or fail("no error this cell")))', 'view traceback for error in current cell')
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')

TextSheet.addCommand('^O', 'sysopen-sheet', 'sheet.sysopen(sheet.cursorRowIndex)', 'open copy of text sheet in $EDITOR and reload on exit')


TextSheet.options.save_filetype = 'txt'

vd.addGlobals({'TextSheet': TextSheet, 'ErrorSheet': ErrorSheet})
vd.addGlobals({'TextSheet': TextSheet, 'ErrorSheet': ErrorSheet, 'ErrorCellSheet': ErrorCellSheet})

vd.addMenuItems('''
View > Errors > recent > error-recent
Expand Down
Loading