mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	 demiurg337
					demiurg337
				
			
				
					committed by
					
						 Justin M. Keyes
						Justin M. Keyes
					
				
			
			
				
	
			
			
			 Justin M. Keyes
						Justin M. Keyes
					
				
			
						parent
						
							7fcf2f926f
						
					
				
				
					commit
					9d207fd876
				
			| @@ -74,6 +74,8 @@ static inline void buf_set_changedtick(buf_T *const buf, | |||||||
| static inline void buf_set_changedtick(buf_T *const buf, | static inline void buf_set_changedtick(buf_T *const buf, | ||||||
|                                        const varnumber_T changedtick) |                                        const varnumber_T changedtick) | ||||||
| { | { | ||||||
|  |   typval_T old_val = buf->changedtick_di.di_tv; | ||||||
|  |  | ||||||
| #ifndef NDEBUG | #ifndef NDEBUG | ||||||
|   dictitem_T *const changedtick_di = tv_dict_find( |   dictitem_T *const changedtick_di = tv_dict_find( | ||||||
|       buf->b_vars, S_LEN("changedtick")); |       buf->b_vars, S_LEN("changedtick")); | ||||||
| @@ -87,6 +89,13 @@ static inline void buf_set_changedtick(buf_T *const buf, | |||||||
|   assert(changedtick_di == (dictitem_T *)&buf->changedtick_di); |   assert(changedtick_di == (dictitem_T *)&buf->changedtick_di); | ||||||
| #endif | #endif | ||||||
|   buf->changedtick_di.di_tv.vval.v_number = changedtick; |   buf->changedtick_di.di_tv.vval.v_number = changedtick; | ||||||
|  |  | ||||||
|  |   if (tv_dict_is_watched(buf->b_vars)) { | ||||||
|  |     tv_dict_watcher_notify(buf->b_vars, | ||||||
|  |                            (char *)buf->changedtick_di.di_key, | ||||||
|  |                            &buf->changedtick_di.di_tv, | ||||||
|  |                            &old_val); | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| static inline varnumber_T buf_get_changedtick(const buf_T *const buf) | static inline varnumber_T buf_get_changedtick(const buf_T *const buf) | ||||||
|   | |||||||
| @@ -1,12 +1,13 @@ | |||||||
| local helpers = require('test.functional.helpers')(after_each) | local helpers = require('test.functional.helpers')(after_each) | ||||||
| local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source | local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source | ||||||
|  | local insert = helpers.insert | ||||||
| local eq, next_msg = helpers.eq, helpers.next_msg | local eq, next_msg = helpers.eq, helpers.next_msg | ||||||
| local exc_exec = helpers.exc_exec | local exc_exec = helpers.exc_exec | ||||||
| local command = helpers.command | local command = helpers.command | ||||||
| local eval = helpers.eval | local eval = helpers.eval | ||||||
|  |  | ||||||
|  |  | ||||||
| describe('dictionary change notifications', function() | describe('VimL dictionary notifications', function() | ||||||
|   local channel |   local channel | ||||||
|  |  | ||||||
|   before_each(function() |   before_each(function() | ||||||
| @@ -338,4 +339,22 @@ describe('dictionary change notifications', function() | |||||||
|       eq({'notification', '2', {'foo', {old = 'baz', new = 'bar'}}}, next_msg()) |       eq({'notification', '2', {'foo', {old = 'baz', new = 'bar'}}}, next_msg()) | ||||||
|     end) |     end) | ||||||
|   end) |   end) | ||||||
|  |  | ||||||
|  |   it('for b:changedtick', function() | ||||||
|  |     source([[ | ||||||
|  |       function! OnTickChanged(dict, key, value) | ||||||
|  |         call rpcnotify(g:channel, 'SendChangeTick', a:key, a:value) | ||||||
|  |       endfunction | ||||||
|  |       call dictwatcheradd(b:, 'changedtick', 'OnTickChanged') | ||||||
|  |     ]]) | ||||||
|  |  | ||||||
|  |     insert('t'); | ||||||
|  |     eq({'notification', 'SendChangeTick', {'changedtick', {old = 2, new = 3}}}, | ||||||
|  |        next_msg()) | ||||||
|  |  | ||||||
|  |     command([[call dictwatcherdel(b:, 'changedtick', 'OnTickChanged')]]) | ||||||
|  |     insert('t'); | ||||||
|  |     eq(2, eval('1+1')) -- Still alive? | ||||||
|  |   end) | ||||||
|  |  | ||||||
| end) | end) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user