-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the correct filename when applying settings to an empty buffer #209
Conversation
65b8c87
to
6ce4a81
Compare
Just in case, are you expecting review? |
@xuhdev would you be willing to try this branch and see if it works for you? I have been pretty much AFK on personal projects since I opened this :( . Please let me know either way. Thanks! |
Could you rebase the changes? Looks like I have no permission to push the rebased change. |
I also tested the changes locally and I haven't encountered any problems with either named or unnamed buffers. |
- Rather than just skipping the buffer, say why it was skipped if g:EditorConfig_verbose is truthy. - Don't print the "Applying EditorConfig" message until we're sure we won't be skipping this buffer.
A micro-optimization. Check the exclude patterns first since those can be done on-CPU. Then, if the file isn't pattern-excluded, check for files on disk.
This sets up for a fix in the next commit to use the correct buffer when running in an autocommand.
In an autocmd (e.g., BufNew), `%` may not be the buffer being processed. Use `<afile>` and `<abuf>` in those cases instead.
@xuhdev thanks! I have rebased/resolved/force-pushed. I am going to run with this branch for a little bit just in case I missed anything, and then merge the PR. |
If the buffer had no fileencoding, and we changed fenc to match the Vim-wide encoding, we haven't actually changed the file. However, we have set modified on the buffer by virtue of assigning fenc. In this case, set nomodified since we didn't actually change anything. This affects new buffers created during the VimEnter autocmd.
Hi, recently I have an issue with editorconfig-vim after this PR merged.
set nocompatible
call plug#begin()
Plug 'editorconfig/editorconfig-vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
call plug#end()
autocmd FileType c EditorConfigReload
#include <stdio.h>
int main() {
int x = 1;
printf("%d\n", x);
return 0;
} How to reproduce the problem:
I couldn't reduce |
When running in an autocmd,
%
is not necessarily the buffer the autocmd applies to. Instead, it turns out you have to use<afile>
and<abuf>
for that (ref.). Therefore, change all the references to%
to refer to the relevant buffer by number.Additionally, for consistency, replace
setlocal
calls withsetbufvar()
calls to the numbered buffer. That way, all the changes will affect the same buffer.Fixes #208.