mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-10-31 12:05:57 +00:00 
			
		
		
		
	[ty] Implemented support for "selection range" language server feature (#19567)
This PR adds support for the "selection range" language server feature. This feature was recently requested by a ty user in [this feature request](https://github.com/astral-sh/ty/issues/882). This feature allows a client to implement "smart selection expansion" based on the structure of the parse tree. For example, if you type "shift-ctrl-right-arrow" in VS Code, the current selection will be expanded to include the parent AST node. Conversely, "shift-ctrl-left-arrow" shrinks the selection. We will probably need to tune the granularity of selection expansion based on user feedback. The initial implementation includes most AST nodes, but users may find this to be too fine-grained. We have the option of skipping some AST nodes that are not as meaningful when editing code. Co-authored-by: UnboundVariable <unbound@gmail.com>
This commit is contained in:
		
							parent
							
								
									e867830848
								
							
						
					
					
						commit
						738246627f
					
				
					 8 changed files with 391 additions and 3 deletions
				
			
		|  | @ -7,9 +7,10 @@ use lsp_server::Connection; | |||
| use lsp_types::{ | ||||
|     ClientCapabilities, DeclarationCapability, DiagnosticOptions, DiagnosticServerCapabilities, | ||||
|     HoverProviderCapability, InitializeParams, InlayHintOptions, InlayHintServerCapabilities, | ||||
|     MessageType, SemanticTokensLegend, SemanticTokensOptions, SemanticTokensServerCapabilities, | ||||
|     ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, | ||||
|     TextDocumentSyncOptions, TypeDefinitionProviderCapability, Url, WorkDoneProgressOptions, | ||||
|     MessageType, SelectionRangeProviderCapability, SemanticTokensLegend, SemanticTokensOptions, | ||||
|     SemanticTokensServerCapabilities, ServerCapabilities, SignatureHelpOptions, | ||||
|     TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, | ||||
|     TypeDefinitionProviderCapability, Url, WorkDoneProgressOptions, | ||||
| }; | ||||
| use ruff_db::system::System; | ||||
| use std::num::NonZeroUsize; | ||||
|  | @ -241,6 +242,7 @@ impl Server { | |||
|                 trigger_characters: Some(vec!['.'.to_string()]), | ||||
|                 ..Default::default() | ||||
|             }), | ||||
|             selection_range_provider: Some(SelectionRangeProviderCapability::Simple(true)), | ||||
|             document_symbol_provider: Some(lsp_types::OneOf::Left(true)), | ||||
|             workspace_symbol_provider: Some(lsp_types::OneOf::Left(true)), | ||||
|             ..Default::default() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 UnboundVariable
						UnboundVariable