Make idle-timeout configurable
This commit is contained in:
parent
c7f3a971c0
commit
633b981db2
@ -19,6 +19,7 @@ ## Editor
|
|||||||
| `line-number` | Line number display (`absolute`, `relative`) | `absolute` |
|
| `line-number` | Line number display (`absolute`, `relative`) | `absolute` |
|
||||||
| `smart-case` | Enable smart case regex searching (case insensitive unless pattern contains upper case characters) | `true` |
|
| `smart-case` | Enable smart case regex searching (case insensitive unless pattern contains upper case characters) | `true` |
|
||||||
| `auto-pairs` | Enable automatic insertion of pairs to parenthese, brackets, etc. | `true` |
|
| `auto-pairs` | Enable automatic insertion of pairs to parenthese, brackets, etc. | `true` |
|
||||||
|
| `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` |
|
||||||
|
|
||||||
## LSP
|
## LSP
|
||||||
|
|
||||||
|
@ -4130,7 +4130,7 @@ pub fn completion(cx: &mut Context) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if items.is_empty() {
|
if items.is_empty() {
|
||||||
editor.set_error("No completion available".to_string());
|
// editor.set_error("No completion available".to_string());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let size = compositor.size();
|
let size = compositor.size();
|
||||||
@ -4138,7 +4138,14 @@ pub fn completion(cx: &mut Context) {
|
|||||||
.find(std::any::type_name::<ui::EditorView>())
|
.find(std::any::type_name::<ui::EditorView>())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if let Some(ui) = ui.as_any_mut().downcast_mut::<ui::EditorView>() {
|
if let Some(ui) = ui.as_any_mut().downcast_mut::<ui::EditorView>() {
|
||||||
ui.set_completion(editor, items, offset_encoding, start_offset, trigger_offset, size);
|
ui.set_completion(
|
||||||
|
editor,
|
||||||
|
items,
|
||||||
|
offset_encoding,
|
||||||
|
start_offset,
|
||||||
|
trigger_offset,
|
||||||
|
size,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -26,6 +26,14 @@
|
|||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
fn deserialize_duration_millis<'de, D>(deserializer: D) -> Result<Duration, D::Error>
|
||||||
|
where
|
||||||
|
D: serde::Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let millis = u64::deserialize(deserializer)?;
|
||||||
|
Ok(Duration::from_millis(millis))
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||||
#[serde(rename_all = "kebab-case", default)]
|
#[serde(rename_all = "kebab-case", default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
@ -45,6 +53,9 @@ pub struct Config {
|
|||||||
pub smart_case: bool,
|
pub smart_case: bool,
|
||||||
/// Automatic insertion of pairs to parentheses, brackets, etc. Defaults to true.
|
/// Automatic insertion of pairs to parentheses, brackets, etc. Defaults to true.
|
||||||
pub auto_pairs: bool,
|
pub auto_pairs: bool,
|
||||||
|
/// Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. Defaults to 400ms.
|
||||||
|
#[serde(skip_serializing, deserialize_with = "deserialize_duration_millis")]
|
||||||
|
pub idle_timeout: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
@ -72,6 +83,7 @@ fn default() -> Self {
|
|||||||
middle_click_paste: true,
|
middle_click_paste: true,
|
||||||
smart_case: true,
|
smart_case: true,
|
||||||
auto_pairs: true,
|
auto_pairs: true,
|
||||||
|
idle_timeout: Duration::from_millis(400),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user