internal: Make autoclosing angle brackets configurable, disabled by default
This commit is contained in:
parent
d7c147406e
commit
f02c915eb5
@ -342,11 +342,16 @@ pub fn on_char_typed(
|
||||
&self,
|
||||
position: FilePosition,
|
||||
char_typed: char,
|
||||
autoclose: bool,
|
||||
) -> Cancellable<Option<SourceChange>> {
|
||||
// Fast path to not even parse the file.
|
||||
if !typing::TRIGGER_CHARS.contains(char_typed) {
|
||||
return Ok(None);
|
||||
}
|
||||
if char_typed == '<' && !autoclose {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
self.with_db(|db| typing::on_char_typed(db, position, char_typed))
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ fn on_char_typed_inner(
|
||||
'<' => on_left_angle_typed(&file.tree(), offset),
|
||||
'>' => conv(on_right_angle_typed(&file.tree(), offset)),
|
||||
'{' => conv(on_opening_brace_typed(file, offset)),
|
||||
_ => unreachable!(),
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
fn conv(text_edit: Option<TextEdit>) -> Option<ExtendedTextEdit> {
|
||||
|
@ -386,6 +386,9 @@ struct ConfigData {
|
||||
/// Show documentation.
|
||||
signatureInfo_documentation_enable: bool = "true",
|
||||
|
||||
/// Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list.
|
||||
typing_autoClosingAngleBrackets_enable: bool = "false",
|
||||
|
||||
/// Workspace symbol search kind.
|
||||
workspace_symbol_search_kind: WorkspaceSymbolSearchKindDef = "\"only_types\"",
|
||||
/// Limits the number of items returned from a workspace symbol search (Defaults to 128).
|
||||
@ -1220,6 +1223,10 @@ pub fn prime_caches_num_threads(&self) -> u8 {
|
||||
n => n,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn typing_autoclose_angle(&self) -> bool {
|
||||
self.data.typing_autoClosingAngleBrackets_enable
|
||||
}
|
||||
}
|
||||
// Deserialization definitions
|
||||
|
||||
|
@ -299,7 +299,8 @@ pub(crate) fn handle_on_type_formatting(
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let edit = snap.analysis.on_char_typed(position, char_typed)?;
|
||||
let edit =
|
||||
snap.analysis.on_char_typed(position, char_typed, snap.config.typing_autoclose_angle())?;
|
||||
let edit = match edit {
|
||||
Some(it) => it,
|
||||
None => return Ok(None),
|
||||
|
@ -593,6 +593,11 @@ Show full signature of the callable. Only shows parameters if disabled.
|
||||
--
|
||||
Show documentation.
|
||||
--
|
||||
[[rust-analyzer.typing.autoClosingAngleBrackets.enable]]rust-analyzer.typing.autoClosingAngleBrackets.enable (default: `false`)::
|
||||
+
|
||||
--
|
||||
Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list.
|
||||
--
|
||||
[[rust-analyzer.workspace.symbol.search.kind]]rust-analyzer.workspace.symbol.search.kind (default: `"only_types"`)::
|
||||
+
|
||||
--
|
||||
|
@ -1068,6 +1068,11 @@
|
||||
"default": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"rust-analyzer.typing.autoClosingAngleBrackets.enable": {
|
||||
"markdownDescription": "Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list.",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"rust-analyzer.workspace.symbol.search.kind": {
|
||||
"markdownDescription": "Workspace symbol search kind.",
|
||||
"default": "only_types",
|
||||
|
Loading…
Reference in New Issue
Block a user