File tree 6 files changed +25
-2
lines changed
6 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -342,11 +342,16 @@ impl Analysis {
342
342
& self ,
343
343
position : FilePosition ,
344
344
char_typed : char ,
345
+ autoclose : bool ,
345
346
) -> Cancellable < Option < SourceChange > > {
346
347
// Fast path to not even parse the file.
347
348
if !typing:: TRIGGER_CHARS . contains ( char_typed) {
348
349
return Ok ( None ) ;
349
350
}
351
+ if char_typed == '<' && !autoclose {
352
+ return Ok ( None ) ;
353
+ }
354
+
350
355
self . with_db ( |db| typing:: on_char_typed ( db, position, char_typed) )
351
356
}
352
357
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ fn on_char_typed_inner(
92
92
'<' => on_left_angle_typed ( & file. tree ( ) , offset) ,
93
93
'>' => conv ( on_right_angle_typed ( & file. tree ( ) , offset) ) ,
94
94
'{' => conv ( on_opening_brace_typed ( file, offset) ) ,
95
- _ => unreachable ! ( ) ,
95
+ _ => return None ,
96
96
} ;
97
97
98
98
fn conv ( text_edit : Option < TextEdit > ) -> Option < ExtendedTextEdit > {
Original file line number Diff line number Diff line change @@ -386,6 +386,9 @@ config_data! {
386
386
/// Show documentation.
387
387
signatureInfo_documentation_enable: bool = "true" ,
388
388
389
+ /// Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list.
390
+ typing_autoClosingAngleBrackets_enable: bool = "false" ,
391
+
389
392
/// Workspace symbol search kind.
390
393
workspace_symbol_search_kind: WorkspaceSymbolSearchKindDef = "\" only_types\" " ,
391
394
/// Limits the number of items returned from a workspace symbol search (Defaults to 128).
@@ -1220,6 +1223,10 @@ impl Config {
1220
1223
n => n,
1221
1224
}
1222
1225
}
1226
+
1227
+ pub fn typing_autoclose_angle ( & self ) -> bool {
1228
+ self . data . typing_autoClosingAngleBrackets_enable
1229
+ }
1223
1230
}
1224
1231
// Deserialization definitions
1225
1232
Original file line number Diff line number Diff line change @@ -299,7 +299,8 @@ pub(crate) fn handle_on_type_formatting(
299
299
return Ok ( None ) ;
300
300
}
301
301
302
- let edit = snap. analysis . on_char_typed ( position, char_typed) ?;
302
+ let edit =
303
+ snap. analysis . on_char_typed ( position, char_typed, snap. config . typing_autoclose_angle ( ) ) ?;
303
304
let edit = match edit {
304
305
Some ( it) => it,
305
306
None => return Ok ( None ) ,
Original file line number Diff line number Diff line change @@ -593,6 +593,11 @@ Show full signature of the callable. Only shows parameters if disabled.
593
593
--
594
594
Show documentation.
595
595
--
596
+ [[rust-analyzer.typing.autoClosingAngleBrackets.enable]]rust-analyzer.typing.autoClosingAngleBrackets.enable (default: `false` )::
597
+ +
598
+ --
599
+ Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list.
600
+ --
596
601
[[rust-analyzer.workspace.symbol.search.kind]]rust-analyzer.workspace.symbol.search.kind (default: `"only_types"` )::
597
602
+
598
603
--
Original file line number Diff line number Diff line change 1068
1068
"default" : true ,
1069
1069
"type" : " boolean"
1070
1070
},
1071
+ "rust-analyzer.typing.autoClosingAngleBrackets.enable" : {
1072
+ "markdownDescription" : " Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list." ,
1073
+ "default" : false ,
1074
+ "type" : " boolean"
1075
+ },
1071
1076
"rust-analyzer.workspace.symbol.search.kind" : {
1072
1077
"markdownDescription" : " Workspace symbol search kind." ,
1073
1078
"default" : " only_types" ,
You can’t perform that action at this time.
0 commit comments