Commit db8e9f5 1 parent dc418bb commit db8e9f5 Copy full SHA for db8e9f5
File tree 2 files changed +17
-8
lines changed
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -1136,20 +1136,23 @@ impl Client {
1136
1136
Some ( self . call :: < lsp:: request:: CodeActionRequest > ( params) )
1137
1137
}
1138
1138
1139
+ pub fn supports_rename ( & self ) -> bool {
1140
+ let capabilities = self . capabilities . get ( ) . unwrap ( ) ;
1141
+ matches ! (
1142
+ capabilities. rename_provider,
1143
+ Some ( lsp:: OneOf :: Left ( true ) | lsp:: OneOf :: Right ( _) )
1144
+ )
1145
+ }
1146
+
1139
1147
pub fn rename_symbol (
1140
1148
& self ,
1141
1149
text_document : lsp:: TextDocumentIdentifier ,
1142
1150
position : lsp:: Position ,
1143
1151
new_name : String ,
1144
1152
) -> Option < impl Future < Output = Result < lsp:: WorkspaceEdit > > > {
1145
- let capabilities = self . capabilities . get ( ) . unwrap ( ) ;
1146
-
1147
- // Return early if the language server does not support renaming.
1148
- match capabilities. rename_provider {
1149
- Some ( lsp:: OneOf :: Left ( true ) ) | Some ( lsp:: OneOf :: Right ( _) ) => ( ) ,
1150
- // None | Some(false)
1151
- _ => return None ,
1152
- } ;
1153
+ if !self . supports_rename ( ) {
1154
+ return None ;
1155
+ }
1153
1156
1154
1157
let params = lsp:: RenameParams {
1155
1158
text_document_position : lsp:: TextDocumentPositionParams {
Original file line number Diff line number Diff line change @@ -1316,6 +1316,12 @@ pub fn rename_symbol(cx: &mut Context) {
1316
1316
let language_server = language_server ! ( cx. editor, doc) ;
1317
1317
let offset_encoding = language_server. offset_encoding ( ) ;
1318
1318
1319
+ if !language_server. supports_rename ( ) {
1320
+ cx. editor
1321
+ . set_error ( "Language server does not support symbol renaming" ) ;
1322
+ return ;
1323
+ }
1324
+
1319
1325
let pos = doc. position ( view. id , offset_encoding) ;
1320
1326
1321
1327
match language_server. prepare_rename ( doc. identifier ( ) , pos) {
You can’t perform that action at this time.
0 commit comments