chrisbra / Recover.vim

A Plugin to show a diff, whenever recovering a buffer
http://www.vim.org/scripts/script.php?script_id=3068
247 stars 25 forks source link

[contrib] cvim does not work correctly on filenames containing spaces #33

Closed matjon closed 9 years ago

matjon commented 9 years ago

Hello,

Steps to reproduce:

  1. cd /tmp
  2. vim 'testing file.txt'
  3. Write some text.
  4. Wait a bit, so that vim will dump everythg to the swapfile.
  5. Kill this vim instance with SIGKILL (e.g. Ctrl+Z, jobs -l, kill 30464 -s SIGKILL). (actually this sequence of commands does make vim save the file somehow)
  6. cvim

Vim will then print the following error message:

E305: Nie znaleziono pliku wymiany dla .testing
Naciśnij ENTER lub wprowadź komendę aby kontynuować

Rough translation:

E305: Cannot find swap file for .testing
Press ENTER

mateusz@mateusz-ubuntu:/tmp$ cvim
Found: 1 swap file (mtime):
  .testing file.txt.swp (11/11/14 12:30:56)
2 plików do edycji
Skipping .testing file.txt.swp: vim exited with error code 1
mateusz@mateusz-ubuntu:/tmp$ ll

Fortunately this does not destroy any data (though I did not do extensive tests).

Cvim was modified a bit to disable checking for a running vim instance as I did not want to install psutils. This should not affect the described behaviour, though.

matjon commented 9 years ago

This will probably also affect the -r command line option, when processing directories with names containing spaces.

matjon commented 9 years ago

Non-ASCII names in files are also not supported:

  1. cd /tmp
  2. vim testowyąęśżńðśą.txt

(3-6. as before)

mateusz@mateusz-ubuntu:/tmp$ cvim
Traceback (most recent call last):
  File "/home/mateusz/bin/cvim", line 266, in <module>
    swap = Swap(sp)
  File "/home/mateusz/bin/cvim", line 111, in __init__
    self.swap = swap.decode(encoding)
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 8-15: ordinal not in range(128)
mateusz@mateusz-ubuntu:/tmp$ 

(it's probably related somehow)

chrisbra commented 9 years ago

I am not a python programmer. I'll try to look into this, when I get some spare time, but this probably won't happen any time soon