google / vim-codefmt

Vim plugin for syntax-aware code formatting
Apache License 2.0
1.11k stars 114 forks source link

Ignore non-zero exit code from clang-format --version #144

Closed dbarnett closed 4 years ago

dbarnett commented 4 years ago

Also make version check logic a little more explicit and fix quirks for empty version or comparing shorter versions.

Resolves a ShellError bug when invoking some versions of the clang-format tool that return non-zero exit code, and instead makes it so if the tool returns a parseable version number it will be used regardless of exit code.

The material change was just updating .Call() to .Call(0), but I refactored the version check logic a little in the process to make sure the scenario of empty version number is handled properly. Also adjusts the logic for comparing versions of mismatched lengths to pad version with zeros instead of checking length only, which could false negative on long min version values.

Fixes #84 .