mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	fix(shada): update marks when using delmarks! (#24978)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							36cb3262b9
						
					
				
				
					commit
					517dfdf0fc
				
			@@ -925,7 +925,24 @@ void ex_delmarks(exarg_T *eap)
 | 
			
		||||
 | 
			
		||||
  if (*eap->arg == NUL && eap->forceit) {
 | 
			
		||||
    // clear all marks
 | 
			
		||||
    clrallmarks(curbuf);
 | 
			
		||||
    const Timestamp timestamp = os_time();
 | 
			
		||||
    for (size_t i = 0; i < NMARKS; i++) {
 | 
			
		||||
      curbuf->b_namedm[i].mark.lnum = 0;
 | 
			
		||||
      curbuf->b_namedm[i].timestamp = timestamp;
 | 
			
		||||
    }
 | 
			
		||||
    curbuf->b_last_cursor.timestamp = timestamp;
 | 
			
		||||
    CLEAR_FMARK(&curbuf->b_last_cursor);
 | 
			
		||||
    curbuf->b_last_cursor.mark.lnum = 1;
 | 
			
		||||
    curbuf->b_last_insert.timestamp = timestamp;
 | 
			
		||||
    CLEAR_FMARK(&curbuf->b_last_insert);
 | 
			
		||||
    curbuf->b_last_change.timestamp = timestamp;
 | 
			
		||||
    CLEAR_FMARK(&curbuf->b_last_change);
 | 
			
		||||
    curbuf->b_op_start.lnum = 0;  // start/end op mark cleared
 | 
			
		||||
    curbuf->b_op_end.lnum = 0;
 | 
			
		||||
    for (int i = 0; i < curbuf->b_changelistlen; i++) {
 | 
			
		||||
      clear_fmark(&curbuf->b_changelist[i]);
 | 
			
		||||
    }
 | 
			
		||||
    curbuf->b_changelistlen = 0;
 | 
			
		||||
  } else if (eap->forceit) {
 | 
			
		||||
    emsg(_(e_invarg));
 | 
			
		||||
  } else if (*eap->arg == NUL) {
 | 
			
		||||
 
 | 
			
		||||
@@ -272,4 +272,26 @@ describe('ShaDa support code', function()
 | 
			
		||||
    eq('Vim(normal):E20: Mark not set', exc_exec('normal! `a'))
 | 
			
		||||
    eq('Vim(normal):E20: Mark not set', exc_exec('normal! `.'))
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('updates deleted marks with :delmarks!', function()
 | 
			
		||||
    nvim_command('edit ' .. testfilename)
 | 
			
		||||
 | 
			
		||||
    nvim_command('mark A')
 | 
			
		||||
    nvim_command('mark a')
 | 
			
		||||
    feed('ggifoobar<esc>')
 | 
			
		||||
    nvim_command('wshada')
 | 
			
		||||
 | 
			
		||||
    reset()
 | 
			
		||||
    nvim_command('edit ' .. testfilename)
 | 
			
		||||
    nvim_command('normal! `A`a`.')
 | 
			
		||||
    nvim_command('delmarks!')
 | 
			
		||||
    nvim_command('wshada')
 | 
			
		||||
 | 
			
		||||
    reset()
 | 
			
		||||
    nvim_command('edit ' .. testfilename)
 | 
			
		||||
    eq('Vim(normal):E20: Mark not set', exc_exec('normal! `a'))
 | 
			
		||||
    eq('Vim(normal):E20: Mark not set', exc_exec('normal! `.'))
 | 
			
		||||
    -- Make sure that uppercase marks aren't deleted.
 | 
			
		||||
    nvim_command('normal! `A')
 | 
			
		||||
  end)
 | 
			
		||||
end)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user