mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	 168bf0024e
			
		
	
	168bf0024e
	
	
	
		
			
			Problem: The previous fix in #34314 relies on copying the tree in `tree_root` to ensure the `TSNode`'s tree cannot be mutated. But that causes the problem where two calls to `tree_root` return nodes from different copies of a tree, which do not compare as equal. This has broken at least one plugin. Solution: Make all `TSTree`s on the Lua side always immutable, avoiding the need to copy the tree in `tree_root`, and make the only mutation point, `tree_edit`, copy the tree instead.
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
| ---@meta
 | |
| -- luacheck: no unused args
 | |
| error('Cannot require a meta file')
 | |
| 
 | |
| --- @brief A "treesitter tree" represents the parsed contents of a buffer, which can be
 | |
| --- used to perform further analysis. It is a |userdata| reference to an object
 | |
| --- held by the treesitter library.
 | |
| ---
 | |
| --- An instance `TSTree` of a treesitter tree supports the following methods.
 | |
| 
 | |
| ---@nodoc
 | |
| ---@class TSTree: userdata
 | |
| local TSTree = {} -- luacheck: no unused
 | |
| 
 | |
| --- Return the root node of this tree.
 | |
| ---@return TSNode
 | |
| function TSTree:root() end
 | |
| 
 | |
| -- stylua: ignore
 | |
| ---@param start_byte integer
 | |
| ---@param end_byte_old integer
 | |
| ---@param end_byte_new integer
 | |
| ---@param start_row integer
 | |
| ---@param start_col integer
 | |
| ---@param end_row_old integer
 | |
| ---@param end_col_old integer
 | |
| ---@param end_row_new integer
 | |
| ---@param end_col_new integer
 | |
| ---@return TSTree
 | |
| ---@nodoc
 | |
| function TSTree:edit(start_byte, end_byte_old, end_byte_new, start_row, start_col, end_row_old, end_col_old, end_row_new, end_col_new) end
 | |
| 
 | |
| --- Returns a copy of the `TSTree`.
 | |
| ---@return TSTree
 | |
| function TSTree:copy() end
 | |
| 
 | |
| ---@param include_bytes true
 | |
| ---@return Range6[]
 | |
| ---@nodoc
 | |
| function TSTree:included_ranges(include_bytes) end
 | |
| 
 | |
| ---@param include_bytes false
 | |
| ---@return Range4[]
 | |
| ---@nodoc
 | |
| function TSTree:included_ranges(include_bytes) end
 |