summaryrefslogtreecommitdiffstats
path: root/src/scriptfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scriptfile.c')
-rw-r--r--src/scriptfile.c62
1 files changed, 50 insertions, 12 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 6dc5557..d5ec7cf 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -215,6 +215,9 @@ estack_sfile(estack_arg_T which UNUSED)
if (*class_name != NUL)
{
// For class methods prepend "<class name>." to the function name.
+ ga_concat(&ga, (char_u *)"<SNR>");
+ ga.ga_len += vim_snprintf((char *)ga.ga_data + ga.ga_len, 23,
+ "%d_", entry->es_info.ufunc->uf_script_ctx.sc_sid);
ga_concat(&ga, class_name);
ga_append(&ga, '.');
}
@@ -402,6 +405,43 @@ get_new_scriptitem_for_fname(int *error, char_u *fname)
return sid;
}
+/*
+ * If the script for "sid" is a symlink and "sn_source_sid" is not set
+ * then initialize it. A new script_item is created if needed.
+ */
+ void
+check_script_symlink(int sid)
+{
+ scriptitem_T *si = SCRIPT_ITEM(sid);
+ if (si->sn_syml_checked || si->sn_sourced_sid > 0)
+ return;
+ si->sn_syml_checked = TRUE;
+
+ // If fname is a symbolic link, create an script_item for the real file.
+
+ char_u *real_fname = fix_fname(si->sn_name);
+ if (real_fname != NULL && STRCMP(real_fname, si->sn_name) != 0)
+ {
+ int real_sid = find_script_by_name(real_fname);
+ int error2 = OK;
+ int new_sid = FALSE;
+ if (real_sid < 0)
+ {
+ real_sid = get_new_scriptitem_for_fname(&error2, real_fname);
+ new_sid = TRUE;
+ }
+ if (error2 == OK)
+ {
+ si = SCRIPT_ITEM(sid);
+ si->sn_sourced_sid = real_sid;
+ if (new_sid)
+ SCRIPT_ITEM(real_sid)->sn_import_autoload
+ = si->sn_import_autoload;
+ }
+ }
+ vim_free(real_fname);
+}
+
static void
find_script_callback(char_u *fname, void *cookie)
{
@@ -1233,7 +1273,7 @@ cmd_source(char_u *fname, exarg_T *eap)
emsg(_(e_argument_required));
else
// source ex commands from the current buffer
- do_source_ext(NULL, FALSE, FALSE, NULL, eap, clearvars);
+ do_source_ext(NULL, FALSE, DOSO_NONE, NULL, eap, clearvars);
}
else if (eap != NULL && eap->forceit)
// ":source!": read Normal mode commands
@@ -1384,14 +1424,17 @@ do_source_buffer_init(source_cookie_T *sp, exarg_T *eap)
char_u *line = NULL;
char_u *fname;
- CLEAR_FIELD(*sp);
-
if (curbuf == NULL)
return NULL;
// Use ":source buffer=<num>" as the script name
- vim_snprintf((char *)IObuff, IOSIZE, ":source buffer=%d", curbuf->b_fnum);
- fname = vim_strsave(IObuff);
+ if (curbuf->b_ffname != NULL)
+ fname = vim_strsave(curbuf->b_ffname);
+ else
+ {
+ vim_snprintf((char *)IObuff, IOSIZE, ":source buffer=%d", curbuf->b_fnum);
+ fname = vim_strsave(IObuff);
+ }
if (fname == NULL)
return NULL;
@@ -1408,6 +1451,8 @@ do_source_buffer_init(source_cookie_T *sp, exarg_T *eap)
}
sp->buf_lnum = 0;
sp->source_from_buf = TRUE;
+ // When sourcing a range of lines from a buffer, use buffer line number.
+ sp->sourcing_lnum = eap->line1 - 1;
return fname;
@@ -1596,13 +1641,6 @@ do_source_ext(
cookie.fileformat = EOL_UNKNOWN;
#endif
- if (fname == NULL)
- // When sourcing a range of lines from a buffer, use the buffer line
- // number.
- cookie.sourcing_lnum = eap->line1 - 1;
- else
- cookie.sourcing_lnum = 0;
-
#ifdef FEAT_EVAL
// Check if this script has a breakpoint.
cookie.breakpoint = dbg_find_breakpoint(TRUE, fname_exp, (linenr_T)0);