Repository: saulpw/visidata

Issue:
'v' (wrap text) reloads from source, undoing sheet modifications
I've noticed some odd side effects when using 'v' (text wrapping).
- When a row has been deleted (d), and then wrapping applied (v) the row will reappear

To test:
echo -e "abc\nDELETEME\n123\n456" | vd -
- delete the row DELETEME with 'd'
- Now apply wrapping with 'v'
The DELETEME row appears


Discussion:
++ for your reproducing steps @geekscrapy 
Ah, I see what is happening. I do not think this will be an easy fix.

The `v` (`textwrap`) reloads the source data in order to do its thing, 

You may notice that the row you cut is still available in the clipboard (just try `paste`ing it). The clipboard has not been undone, the sheet reloaded. Try modifying any of the cells, or adding a row. Those will also get reloaded.

I think the idea was that most people will textwrap *before* they actually do anything with the sheet. 

This will require feedback from @saulpw for how we proceed. I think at minimum, there should be a status message informing the user that text wrap reloaded the sheet from source. We did have a plan to review the `visibility` commands, in general. 
Thanks the bug report, @geekscrapy, and @anjakefala for preliminary investigation.  Multi-line row functionality should completely supplant the TextSheet 'v' command, so we should just remove this command entirely.  Then the `wrap` option could be set on the CLI, or you could toggle it manually and reload (as with other loader options).  And if you wanted more fluid textwrapping toggle, you'd use the standard `v` to toggle multi-line rows.

I've been holding off on doing this because multi-line rows are still buggy and I haven't felt 100% committed to keeping it in 2.0; and wrapping functionality for TextSheets is especially important.  This issue pushes me a little closer to just biting the bullet (though I still don't know how to fix multi-line rows properly, unfortunately).
:+1: That makes sense to me. I can make the change, and we can see how we feel. 

I think moving textwrap to commandline is more upfront about the fact that it is a upon-reload command, regardless of if we end up committing to multi-line rows. 

~~Do we want to keep an unbound variant of it for users who know how it behaves, and want to go for it anyway?~~

**EDIT**: Nevermind, re-read your comment about toggling it manually! I know what to do. =)

Resolving patch:
diff --git a/visidata/textsheet.py b/visidata/textsheet.py
--- a/visidata/textsheet.py
+++ b/visidata/textsheet.py
@@ -56,6 +56,4 @@ def recentErrorsSheet(self):
 Sheet.addCommand(None, 'view-cell', 'vd.push(ErrorSheet("%s[%s].%s" % (name, cursorRowIndex, cursorCol.name), source=sheet, lines=cursorDisplay.splitlines()))', 'view contents of current cell in a new sheet'),
 Sheet.addCommand('z^E', 'error-cell', 'vd.push(ErrorSheet(sheet.name+"_cell_error", source=sheet, lines=getattr(cursorCell, "error", None) or fail("no error this cell")))', 'view traceback for error in current cell')
 
-TextSheet.addCommand('v', 'visibility', 'sheet.options.wrap = not sheet.options.wrap; reload(); status("text%s wrapped" % ("" if sheet.options.wrap else " NOT")); ')
-
 TextSheet.options.save_filetype = 'txt'


Test patch: