[all-commits] [llvm/llvm-project] 862781: [clang-format] Support new file formatting with vim

Jinsong Ji via All-commits all-commits at lists.llvm.org
Mon Nov 21 13:20:01 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 86278114085bdce39b9cf1895447070454bb5fe3
      https://github.com/llvm/llvm-project/commit/86278114085bdce39b9cf1895447070454bb5fe3
  Author: Ji, Jinsong <jinsong.ji at intel.com>
  Date:   2022-11-21 (Mon, 21 Nov 2022)

  Changed paths:
    M clang/tools/clang-format/clang-format.py

  Log Message:
  -----------
  [clang-format] Support new file formatting with vim

The vim Formatonsave integration is not working if we create a new file directly using vim.
eg: vi -V9t.log t.cpp

It will not able to format the buffer.

> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "...clang/tools/clang-format/clang-format.py", line 156, in <module>
>     main()
>   File "...clang/tools/clang-format/clang-format.py", line 80, in main
>     with open(vim.current.buffer.name, 'r') as f:
> FileNotFoundError: [Errno 2] No such file or directory: '...t.cpp'

This patch check the file before we try to open it.

Reviewed By: owenpan

Differential Revision: https://reviews.llvm.org/D138234




More information about the All-commits mailing list