Change summary
assets/keymaps/default.json | 8 +++++++-
crates/editor/src/editor.rs | 11 ++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
Detailed changes
@@ -164,7 +164,7 @@
"bindings": {
"enter": "editor::Newline",
"cmd-shift-enter": "editor::NewlineAbove",
- "cmd-enter": "ai::Assist",
+ "cmd-enter": "editor::NewlineBelow",
"alt-z": "editor::ToggleSoftWrap",
"cmd-f": [
"buffer_search::Deploy",
@@ -183,6 +183,12 @@
"alt-[": "copilot::PreviousSuggestion"
}
},
+ {
+ "context": "Editor && extension == zmd",
+ "bindings": {
+ "cmd-enter": "ai::Assist"
+ }
+ },
{
"context": "Editor && mode == auto_height",
"bindings": {
@@ -7231,7 +7231,7 @@ impl View for Editor {
false
}
- fn update_keymap_context(&self, keymap: &mut KeymapContext, _: &AppContext) {
+ fn update_keymap_context(&self, keymap: &mut KeymapContext, cx: &AppContext) {
Self::reset_to_default_keymap_context(keymap);
let mode = match self.mode {
EditorMode::SingleLine => "single_line",
@@ -7250,6 +7250,15 @@ impl View for Editor {
for layer in self.keymap_context_layers.values() {
keymap.extend(layer);
}
+
+ if let Some(extension) = self
+ .buffer
+ .read(cx)
+ .as_singleton()
+ .and_then(|buffer| buffer.read(cx).file()?.path().extension()?.to_str())
+ {
+ keymap.add_key("extension", extension.to_string());
+ }
}
fn text_for_range(&self, range_utf16: Range<usize>, cx: &AppContext) -> Option<String> {