mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
vim-patch:8.2.2332: Vim9: missing :endif not reported when using :windo (#28482)
Problem: Vim9: missing :endif not reported when using :windo.
Solution: Pass a getline function to do_cmdline(). (closes vim/vim#7650)
9567efa1b4
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
c81b7849a0
commit
7d28c427e3
@ -69,7 +69,7 @@
|
|||||||
/// It is shared between do_source() and getsourceline().
|
/// It is shared between do_source() and getsourceline().
|
||||||
/// This is required, because it needs to be handed to do_cmdline() and
|
/// This is required, because it needs to be handed to do_cmdline() and
|
||||||
/// sourcing can be done recursively.
|
/// sourcing can be done recursively.
|
||||||
struct source_cookie {
|
typedef struct {
|
||||||
FILE *fp; ///< opened file for sourcing
|
FILE *fp; ///< opened file for sourcing
|
||||||
char *nextline; ///< if not NULL: line that was read ahead
|
char *nextline; ///< if not NULL: line that was read ahead
|
||||||
linenr_T sourcing_lnum; ///< line number of the source file
|
linenr_T sourcing_lnum; ///< line number of the source file
|
||||||
@ -83,7 +83,7 @@ struct source_cookie {
|
|||||||
int dbg_tick; ///< debug_tick when breakpoint was set
|
int dbg_tick; ///< debug_tick when breakpoint was set
|
||||||
int level; ///< top nesting level of sourced file
|
int level; ///< top nesting level of sourced file
|
||||||
vimconv_T conv; ///< type of conversion
|
vimconv_T conv; ///< type of conversion
|
||||||
};
|
} source_cookie_T;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *path;
|
char *path;
|
||||||
@ -1822,20 +1822,20 @@ void ex_options(exarg_T *eap)
|
|||||||
/// @return address holding the next breakpoint line for a source cookie
|
/// @return address holding the next breakpoint line for a source cookie
|
||||||
linenr_T *source_breakpoint(void *cookie)
|
linenr_T *source_breakpoint(void *cookie)
|
||||||
{
|
{
|
||||||
return &((struct source_cookie *)cookie)->breakpoint;
|
return &((source_cookie_T *)cookie)->breakpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the address holding the debug tick for a source cookie.
|
/// @return the address holding the debug tick for a source cookie.
|
||||||
int *source_dbg_tick(void *cookie)
|
int *source_dbg_tick(void *cookie)
|
||||||
{
|
{
|
||||||
return &((struct source_cookie *)cookie)->dbg_tick;
|
return &((source_cookie_T *)cookie)->dbg_tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the nesting level for a source cookie.
|
/// @return the nesting level for a source cookie.
|
||||||
int source_level(void *cookie)
|
int source_level(void *cookie)
|
||||||
FUNC_ATTR_PURE
|
FUNC_ATTR_PURE
|
||||||
{
|
{
|
||||||
return ((struct source_cookie *)cookie)->level;
|
return ((source_cookie_T *)cookie)->level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Special function to open a file without handle inheritance.
|
/// Special function to open a file without handle inheritance.
|
||||||
@ -2052,7 +2052,7 @@ int do_source_str(const char *cmd, const char *traceback_name)
|
|||||||
/// If a scriptitem_T was found or created "*ret_sid" is set to the SID.
|
/// If a scriptitem_T was found or created "*ret_sid" is set to the SID.
|
||||||
int do_source(char *fname, int check_other, int is_vimrc, int *ret_sid)
|
int do_source(char *fname, int check_other, int is_vimrc, int *ret_sid)
|
||||||
{
|
{
|
||||||
struct source_cookie cookie;
|
source_cookie_T cookie;
|
||||||
uint8_t *firstline = NULL;
|
uint8_t *firstline = NULL;
|
||||||
int retval = FAIL;
|
int retval = FAIL;
|
||||||
int save_debug_break_level = debug_break_level;
|
int save_debug_break_level = debug_break_level;
|
||||||
@ -2440,7 +2440,7 @@ linenr_T get_sourced_lnum(LineGetter fgetline, void *cookie)
|
|||||||
FUNC_ATTR_PURE
|
FUNC_ATTR_PURE
|
||||||
{
|
{
|
||||||
return fgetline == getsourceline
|
return fgetline == getsourceline
|
||||||
? ((struct source_cookie *)cookie)->sourcing_lnum
|
? ((source_cookie_T *)cookie)->sourcing_lnum
|
||||||
: SOURCING_LNUM;
|
: SOURCING_LNUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2546,7 +2546,7 @@ void f_getscriptinfo(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
/// some error.
|
/// some error.
|
||||||
char *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
char *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
||||||
{
|
{
|
||||||
struct source_cookie *sp = (struct source_cookie *)cookie;
|
source_cookie_T *sp = (source_cookie_T *)cookie;
|
||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
// If breakpoints have been added/deleted need to check for it.
|
// If breakpoints have been added/deleted need to check for it.
|
||||||
@ -2560,8 +2560,8 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
|||||||
// Set the current sourcing line number.
|
// Set the current sourcing line number.
|
||||||
SOURCING_LNUM = sp->sourcing_lnum + 1;
|
SOURCING_LNUM = sp->sourcing_lnum + 1;
|
||||||
// Get current line. If there is a read-ahead line, use it, otherwise get
|
// Get current line. If there is a read-ahead line, use it, otherwise get
|
||||||
// one now.
|
// one now. "fp" is NULL if actually using a string.
|
||||||
if (sp->finished) {
|
if (sp->finished || sp->fp == NULL) {
|
||||||
line = NULL;
|
line = NULL;
|
||||||
} else if (sp->nextline == NULL) {
|
} else if (sp->nextline == NULL) {
|
||||||
line = get_one_sourceline(sp);
|
line = get_one_sourceline(sp);
|
||||||
@ -2624,7 +2624,7 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_one_sourceline(struct source_cookie *sp)
|
static char *get_one_sourceline(source_cookie_T *sp)
|
||||||
{
|
{
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
int len;
|
int len;
|
||||||
@ -2730,7 +2730,7 @@ retry:
|
|||||||
/// Without the multi-byte feature it's simply ignored.
|
/// Without the multi-byte feature it's simply ignored.
|
||||||
void ex_scriptencoding(exarg_T *eap)
|
void ex_scriptencoding(exarg_T *eap)
|
||||||
{
|
{
|
||||||
struct source_cookie *sp;
|
source_cookie_T *sp;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (!getline_equal(eap->ea_getline, eap->cookie, getsourceline)) {
|
if (!getline_equal(eap->ea_getline, eap->cookie, getsourceline)) {
|
||||||
@ -2745,7 +2745,7 @@ void ex_scriptencoding(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup for conversion from the specified encoding to 'encoding'.
|
// Setup for conversion from the specified encoding to 'encoding'.
|
||||||
sp = (struct source_cookie *)getline_cookie(eap->ea_getline, eap->cookie);
|
sp = (source_cookie_T *)getline_cookie(eap->ea_getline, eap->cookie);
|
||||||
convert_setup(&sp->conv, name, p_enc);
|
convert_setup(&sp->conv, name, p_enc);
|
||||||
|
|
||||||
if (name != eap->arg) {
|
if (name != eap->arg) {
|
||||||
@ -2769,8 +2769,7 @@ void ex_finish(exarg_T *eap)
|
|||||||
void do_finish(exarg_T *eap, bool reanimate)
|
void do_finish(exarg_T *eap, bool reanimate)
|
||||||
{
|
{
|
||||||
if (reanimate) {
|
if (reanimate) {
|
||||||
((struct source_cookie *)getline_cookie(eap->ea_getline,
|
((source_cookie_T *)getline_cookie(eap->ea_getline, eap->cookie))->finished = false;
|
||||||
eap->cookie))->finished = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup (and deactivate) conditionals, but stop when a try conditional
|
// Cleanup (and deactivate) conditionals, but stop when a try conditional
|
||||||
@ -2782,8 +2781,7 @@ void do_finish(exarg_T *eap, bool reanimate)
|
|||||||
eap->cstack->cs_pending[idx] = CSTP_FINISH;
|
eap->cstack->cs_pending[idx] = CSTP_FINISH;
|
||||||
report_make_pending(CSTP_FINISH, NULL);
|
report_make_pending(CSTP_FINISH, NULL);
|
||||||
} else {
|
} else {
|
||||||
((struct source_cookie *)getline_cookie(eap->ea_getline,
|
((source_cookie_T *)getline_cookie(eap->ea_getline, eap->cookie))->finished = true;
|
||||||
eap->cookie))->finished = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2793,7 +2791,7 @@ void do_finish(exarg_T *eap, bool reanimate)
|
|||||||
bool source_finished(LineGetter fgetline, void *cookie)
|
bool source_finished(LineGetter fgetline, void *cookie)
|
||||||
{
|
{
|
||||||
return getline_equal(fgetline, cookie, getsourceline)
|
return getline_equal(fgetline, cookie, getsourceline)
|
||||||
&& ((struct source_cookie *)getline_cookie(fgetline, cookie))->finished;
|
&& ((source_cookie_T *)getline_cookie(fgetline, cookie))->finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the autoload script name for a function or variable name
|
/// Return the autoload script name for a function or variable name
|
||||||
|
Loading…
Reference in New Issue
Block a user