- Notifications
You must be signed in to change notification settings - Fork750
Check if file exists before loading editorconfig settings#3018
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Hello, does this PR seem reasonable? |
rc/detection/editorconfig.kak Outdated
print "autowrap-enable" | ||
print "add-highlighter window/ column %sh{ echo $((" max_line_length "+1)) } default,bright-black" | ||
file="${1:-$kak_buffile}" | ||
if [-f"$file" ];then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
if [ -f"$file" ]; then | |
if [ -e"$file" ]; then |
To handle symlinks.
mawww commentedAug 20, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hello, I dont think the logic should be to disable editorconfig for non-existing files, what we want is to disable it for non-file buffers (scratch buffers in Kakoune lingo). One distinction between file and non-file buffers is that $kak_buffile will be an absolute path for any file buffer, but just match the buffer name for a non-file buffer, so I suspect ignoring all buffers where $kak_buffile does not start with a slash would do the trick. EDIT: Also, sorry for the delay in taking a look at that. |
Check if buffile is a full path by checking for the beginning'/' character in editorconfig-load command. This avoids a parsingerror from feeding a *scratch*/*debug*/*grep*/etc. buffer name to theeditorcofig command. Don't clear editorconfig hooks until after checkingfor a valid bufffile path. This way, opening the *debug* buffer willnot clear the hooks from a previously parsed .editorconfig file. Iftrim_trailing_whitespace is true, print the hook directly from awk. Thisremoves the need to save a editorcofig_trim_trailing_whitespace option.Note: Setting the max_line_length requires a window to be created.Therefore, a global hook to load .editorconfig settings should be: hook global WinCreate .* %{editorconfig-load}
I've updated this PR to check if As mawww suggested, this should work for all unix environments. On Cygwin, it appears you can specify a path that begins with a drive letter (ex: Lastly, if you want to keep the editorconfig.kak script as-is. I've been using a WinCreate hook with regex to filter out buffer names that start with a
|
I noticed when using the recommendededitorconfig hook from the Wiki, that the editorconfig.kak script failed for buffers that were not real files. For example
*scratch*
,*debug*
,*make*
,*grep*
, etc.This PR adds a check in the
editorcofig-load
command to see if a file exists before calling the externaleditorconfig
utility.It also moves the
remove-hooks
line to after the valid file check and directly prints the command to add a remove trailing whitespace hook from awk (if necessary). This prevents an invalid file from clearing a hook and removes the need to store an option and reference it from a spawned shell in the later hook.