clang-format version detection is slightly broken (and definitely so for trunk builds)
- Ngôn ngữ chính
- Vim Script
- Star
- 1.1k
- Fork
- 102
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
At https://github.com/google/vim-codefmt/blob/293c208/autoload/codefmt/clangformat.vim#L32-34, we have this code:
```viml
let l:version_string = matchstr(l:version_output, '\v\d+(.\d+)+')
" If no version string was matched, cached version will be an empty list.
let s:clang_format_version = map(split(l:version_string, '\.'), 'v:val + 0')
```
which is trying to find a version number (possibly "1.2.3" or "1.2" or just "1") in the output of `clang-format --version`:
```sh
$ clang-format --version
clang-format version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
```
However, for trunk builds, the output looks something like:
```sh
clang-format --version
clang-format version mainline (4321b9f2e9842982d13234920a643e3a4657c60b)
```
(where "mainline" can be any string the configurer chooses).
However:
- `matchstr(l:version_output, '\v\d+(.\d+)+')` has `.` matching _any_ character. That probably was intended to be a literal (`\.`) instead, otherwise the pattern could just have been `\v\d.+`.
- As a result, we consider any trunk build to be a version "number" containing the numeric start of the hex string (i.e. version 4321 in the above example).
- This means that we usually consider trunk builds to have all features (good), but only if their version string starts with enough non-zero/non-hex digits (bad).
We probably should do something like:
1. Change the regexp to use `\.` instead to match a literal.
2. Consider a non-standard version to always _have_ the feature rather than not have it (at https://github.com/google/vim-codefmt/blob/293c208/autoload/codefmt/clangformat.vim#L38.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu trong autoload/codefmt/clangformat.vim, tại phần phân tích phiên bản quanh các dòng 32-38, và so sánh hành vi của nó với các đầu ra clang-format --version dạng số và kiểu trunk được hiển thị trong issue. Xác minh rằng các phiên bản dạng ký tự có dấu chấm được phân tích chính xác và các phiên bản không theo tiêu chuẩn nhận được cách xử lý tính năng dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- vim
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100