tweekmonster / wstrip.vim

Strip trailing whitespace only on changed lines
MIT License
16 stars 2 forks source link

Check whether the file is tracked in Git #2

Closed ghost closed 7 years ago

ghost commented 7 years ago

~~If you edit a file in a Git repository that is not yet tracked, :WStrip will error out with something like:~~

Error detected while processing function wstrip#auto[2]..wstrip#clean[12]..<SNR>85_get_diff_lines:
line   19:
E482: Can't create file src/bin/.wstrip.test.rs
Error detected while processing function wstrip#auto[2]..wstrip#clean:
line   12:
"src/bin/test.rs"
"src/bin/test.rs" E212: Can't open file for writing

~~Therefore, for such files we must still use regular diff instead of git giff.~~

ghost commented 7 years ago

Oops, I think this was not really the problem. This error actually happens if I edit a file in a non-existing directory. For example, I edit "src/bin/test.rs", but "src/bin" doesn't exist. Then wstrip errors out. It's not really this plugin's fault. :)

tweekmonster commented 7 years ago

Hmm, but I think the plugin shouldn't do things when it can't do things. Maybe a different PR where buffers with non-existent files are completely ignored.

I think this PR also makes sense. There wouldn't be a need to git diff a file that isn't tracked in the repo.