[vim/vim] When the defaults.vim file cannot be read, output an error message (#8248)

48 views
Skip to first unread message

Christian Brabandt

unread,
May 24, 2021, 5:28:45 AM5/24/21
to vim/vim, Subscribed

When running vim --clean and the defaults.vim runtime file cannot be
loaded, output an error message instead of silent to continue.

That is because if defaults.vim cannot be loaded, vim will start in
defaults mode, which may be unexpected and have quite some different defaults
and therefore behaves differently.

So make the user aware of this situation.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/8248

Commit Summary

  • When the defaults.vim file cannot be read, output an error message

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

codecov[bot]

unread,
May 24, 2021, 5:32:37 AM5/24/21
to vim/vim, Subscribed

Codecov Report

Merging #8248 (927b2d2) into master (f5409db) will decrease coverage by 86.99%.
The diff coverage is n/a.

Current head 927b2d2 differs from pull request most recent head c598d88. Consider uploading reports for the commit c598d88 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@

##           master    #8248       +/-   ##

===========================================

- Coverage   89.46%    2.46%   -87.00%     

===========================================

  Files         148      146        -2     

  Lines      166969   161828     -5141     

===========================================

- Hits       149373     3990   -145383     

- Misses      17596   157838   +140242     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 2.46% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main.c 8.96% <ø> (-81.96%) ⬇️
src/sha256.c 0.00% <0.00%> (-97.96%) ⬇️
src/digraph.c 0.00% <0.00%> (-97.78%) ⬇️
src/gui_gtk_f.c 0.00% <0.00%> (-97.54%) ⬇️
src/match.c 0.00% <0.00%> (-97.13%) ⬇️
src/crypt_zip.c 0.00% <0.00%> (-97.06%) ⬇️
src/evalbuffer.c 0.00% <0.00%> (-96.83%) ⬇️
src/debugger.c 0.00% <0.00%> (-96.62%) ⬇️
src/libvterm/src/rect.h 0.00% <0.00%> (-96.56%) ⬇️
src/textprop.c 0.00% <0.00%> (-96.45%) ⬇️
... and 135 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f5409db...c598d88. Read the comment docs.

Bram Moolenaar

unread,
May 28, 2021, 1:21:53 PM5/28/21
to vim/vim, Subscribed

putting the do_source() call inside the "if" changes the logic, if OK is returned it continues with "else".

There is no % in the error message, use "emsg()" instead of "semsg()".

Add the error message in src/errors.h with a variable name as other errors.

Please add a test.

Christian Brabandt

unread,
May 29, 2021, 12:13:08 PM5/29/21
to vim/vim, Subscribed

thanks, adjusted according to your feedback

Christian Brabandt

unread,
May 29, 2021, 12:31:28 PM5/29/21
to vim/vim, Push

@chrisbra pushed 1 commit.


You are receiving this because you are subscribed to this thread.

View it on GitHub or unsubscribe.

Christian Brabandt

unread,
May 29, 2021, 12:53:39 PM5/29/21
to vim/vim, Subscribed

not sure why there is an ASAN error

Bram Moolenaar

unread,
May 29, 2021, 1:54:25 PM5/29/21
to vim/vim, Subscribed

Closed #8248 via 1d3a14e.

Bram Moolenaar

unread,
May 29, 2021, 2:33:52 PM5/29/21
to vim/vim, Subscribed

I thought it was just a stray ASAN error, but it fails again after including the patch.
I cannot reproduce the failure locally.
It looks like it has something to do with not exiting cleanly. But "-cq" is used elsewhere without problems.

Dominique Pellé

unread,
May 29, 2021, 2:58:24 PM5/29/21
to vim/vim, Subscribed

I have not reproduce the leak with asan yet, but glancing at the code in add_termcode() in term.c, I see that the string s can leak. I'll create a PR soon with this fix:

$ git diff term.c
diff --git a/src/term.c b/src/term.c
index 0a4e5b758..a91d2c73e 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4248,6 +4248,7 @@ add_termcode(char_u *name, char_u *string, int flags)
        if (new_tc == NULL)
        {
            tc_max_len -= 20;
+           vim_free(s);
            return;
        }
        for (i = 0; i < tc_len; ++i)

Bram Moolenaar

unread,
May 29, 2021, 3:10:00 PM5/29/21
to vim/vim, Subscribed

I can reproduce it now. The shell command outputs:
E1187: Failed to source defaults.vim\e[?25l\e[J\r\nPress ENTER or type command to continue\e[?25h\e[24;1HVim: Error reading input, exiting...\n\r\nVim: Finished.
It appears the hit enter prompt is the problem.

Reply all
Reply to author
Forward
0 new messages