startup: fix ":if 0|syntax on|endif" bug (#8731)

Problem: ":if 0|syntax {on,off}|endif" skips the default of "syntax on"
because the executor was setting the `did_syntax_onoff` flag even though
"syntax {on,off}" is not actually executed.

closes #8728
This commit is contained in:
Justin M. Keyes 2018-07-18 14:30:11 +02:00 committed by GitHub
parent cd94dd6bb2
commit 489d32f2b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -3425,9 +3425,9 @@ static void syn_cmd_off(exarg_T *eap, int syncing)
static void syn_cmd_onoff(exarg_T *eap, char *name) static void syn_cmd_onoff(exarg_T *eap, char *name)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
did_syntax_onoff = true;
eap->nextcmd = check_nextcmd(eap->arg); eap->nextcmd = check_nextcmd(eap->arg);
if (!eap->skip) { if (!eap->skip) {
did_syntax_onoff = true;
char buf[100]; char buf[100];
memcpy(buf, "so ", 4); memcpy(buf, "so ", 4);
vim_snprintf(buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name); vim_snprintf(buf + 3, sizeof(buf) - 3, SYNTAX_FNAME, name);

View File

@ -118,6 +118,13 @@ describe('startup defaults', function()
clear('-u', 'NORC', '-c', 'syntax off') clear('-u', 'NORC', '-c', 'syntax off')
eq(0, eval('exists("g:syntax_on")')) eq(0, eval('exists("g:syntax_on")'))
end) end)
it('":if 0|syntax on|endif" does not affect default #8728', function()
clear('-u', 'NORC', '--cmd', ':if 0|syntax on|endif')
eq(1, eval('exists("g:syntax_on")'))
clear('-u', 'NORC', '--cmd', ':if 0|syntax off|endif')
eq(1, eval('exists("g:syntax_on")'))
end)
end) end)
describe("'fillchars'", function() describe("'fillchars'", function()