mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(mark): give correct error message when mark is in another buffer (#19454)
This commit is contained in:
@@ -339,11 +339,11 @@ fmark_T *mark_get(buf_T *buf, win_T *win, fmark_T *fmp, MarkGet flag, int name)
|
||||
fmark_T *fm = NULL;
|
||||
if (ASCII_ISUPPER(name) || ascii_isdigit(name)) {
|
||||
// Global marks
|
||||
xfmark_T *xfm = mark_get_global(!(flag & kMarkAllNoResolve), name);
|
||||
xfmark_T *xfm = mark_get_global(flag != kMarkAllNoResolve, name);
|
||||
fm = &xfm->fmark;
|
||||
if (flag == kMarkBufLocal && xfm->fmark.fnum != buf->handle) {
|
||||
// Only wanted marks belonging to the buffer
|
||||
if ((flag & kMarkBufLocal) && xfm->fmark.fnum != buf->handle) {
|
||||
return NULL;
|
||||
return pos_to_mark(buf, NULL, (pos_T){ .lnum = 0 });
|
||||
}
|
||||
} else if (name > 0 && name < NMARK_LOCAL_MAX) {
|
||||
// Local Marks
|
||||
@@ -508,11 +508,12 @@ fmark_T *mark_get_visual(buf_T *buf, int name)
|
||||
/// Pass an fmp if multiple c
|
||||
/// @note view fields are set to 0.
|
||||
/// @param buf for fmark->fnum.
|
||||
/// @param pos for fmrak->mark.
|
||||
/// @param pos for fmark->mark.
|
||||
/// @param fmp pointer to save the mark.
|
||||
///
|
||||
/// @return[static] Mark with the given information.
|
||||
fmark_T *pos_to_mark(buf_T *buf, fmark_T *fmp, pos_T pos)
|
||||
FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
static fmark_T fms = INIT_FMARK;
|
||||
fmark_T *fm = fmp == NULL ? &fms : fmp;
|
||||
|
@@ -3705,8 +3705,6 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
||||
int cmp = OPERAND(scan)[1];
|
||||
pos_T *pos;
|
||||
size_t col = REG_MULTI ? rex.input - rex.line : 0;
|
||||
|
||||
// fm will be NULL if the mark is not set in reg_buf
|
||||
fmark_T *fm = mark_get(rex.reg_buf, curwin, NULL, kMarkBufLocal, mark);
|
||||
|
||||
// Line may have been freed, get it again.
|
||||
|
@@ -6930,10 +6930,8 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
|
||||
case NFA_MARK:
|
||||
case NFA_MARK_GT:
|
||||
case NFA_MARK_LT: {
|
||||
fmark_T *fm;
|
||||
size_t col = REG_MULTI ? rex.input - rex.line : 0;
|
||||
// fm will be NULL if the mark is not set, doesn't belong to reg_buf
|
||||
fm = mark_get(rex.reg_buf, curwin, NULL, kMarkBufLocal, t->state->val);
|
||||
fmark_T *fm = mark_get(rex.reg_buf, curwin, NULL, kMarkBufLocal, t->state->val);
|
||||
|
||||
// Line may have been freed, get it again.
|
||||
if (REG_MULTI) {
|
||||
|
@@ -157,6 +157,13 @@ describe('named marks', function()
|
||||
os.remove(file1)
|
||||
end)
|
||||
|
||||
it("errors when using a mark in another buffer in command range", function()
|
||||
feed('ifoo<Esc>mA')
|
||||
command('enew')
|
||||
feed('ibar<Esc>')
|
||||
eq('Vim(print):E20: Mark not set', pcall_err(command, [['Aprint]]))
|
||||
end)
|
||||
|
||||
it("leave a context mark when moving with '", function()
|
||||
command("edit " .. file1)
|
||||
feed("llmamA")
|
||||
|
Reference in New Issue
Block a user