first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -1,42 +1,36 @@
|
||||
#![cfg_attr(target_family = "wasm", allow(dead_code, unused_imports))]
|
||||
// Adding this file level gate as some of the code around editability is not used in WASM yet.
|
||||
|
||||
use crate::code::editor::{
|
||||
line::EditorLineLocation,
|
||||
model::CodeEditorModel,
|
||||
view::{CodeEditorEvent, CodeEditorView, VimMode},
|
||||
};
|
||||
use crate::{
|
||||
cmd_or_ctrl_shift, code_review::comments::CommentId,
|
||||
code_review::telemetry_event::CodeReviewTelemetryEvent, editor::InteractionState,
|
||||
features::FeatureFlag, notebooks::editor::model::word_unit, send_telemetry_from_ctx,
|
||||
util::bindings::CustomAction,
|
||||
};
|
||||
use galaxy_editor::{
|
||||
content::version::BufferVersion,
|
||||
editor::{EmbeddedItemModel, RunnableCommandModel, TextDecoration},
|
||||
model::{CoreEditorModel, PlainTextEditorModel},
|
||||
render::{
|
||||
element::RichTextAction,
|
||||
model::{ExpansionType, LineCount, Location},
|
||||
},
|
||||
selection::{TextDirection, TextUnit},
|
||||
};
|
||||
use galaxy_util::user_input::UserInput;
|
||||
use galaxyui::{
|
||||
actions::StandardAction,
|
||||
elements::Axis,
|
||||
event::ModifiersState,
|
||||
keymap::{EditableBinding, FixedBinding, Keystroke, PerPlatformKeystroke},
|
||||
units::Pixels,
|
||||
AppContext, TypedActionView, ViewContext, WeakViewHandle,
|
||||
};
|
||||
use lazy_static::lazy_static;
|
||||
use rangemap::RangeSet;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fmt::Debug;
|
||||
use std::ops::Range;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use rangemap::RangeSet;
|
||||
use string_offset::CharOffset;
|
||||
use galaxy_editor::content::version::BufferVersion;
|
||||
use galaxy_editor::editor::{EmbeddedItemModel, RunnableCommandModel, TextDecoration};
|
||||
use galaxy_editor::model::{CoreEditorModel, PlainTextEditorModel};
|
||||
use galaxy_editor::render::element::RichTextAction;
|
||||
use galaxy_editor::render::model::{ExpansionType, LineCount, Location};
|
||||
use galaxy_editor::selection::{TextDirection, TextUnit};
|
||||
use galaxy_util::user_input::UserInput;
|
||||
use galaxyui::actions::StandardAction;
|
||||
use galaxyui::elements::Axis;
|
||||
use galaxyui::event::ModifiersState;
|
||||
use galaxyui::keymap::{EditableBinding, FixedBinding, Keystroke, PerPlatformKeystroke};
|
||||
use galaxyui::units::Pixels;
|
||||
use galaxyui::{AppContext, TypedActionView, ViewContext, WeakViewHandle};
|
||||
|
||||
use crate::cmd_or_ctrl_shift;
|
||||
use crate::code::editor::line::EditorLineLocation;
|
||||
use crate::code::editor::model::CodeEditorModel;
|
||||
use crate::code::editor::view::{CodeEditorEvent, CodeEditorView, VimMode};
|
||||
use crate::code_review::comments::CommentId;
|
||||
use crate::editor::InteractionState;
|
||||
use crate::features::FeatureFlag;
|
||||
use crate::notebooks::editor::model::word_unit;
|
||||
use crate::util::bindings::CustomAction;
|
||||
|
||||
/// Limit the keybindings that conflict with the Agent Mode embedded editor.
|
||||
const NON_EDITABLE_KEYMAP_CONTEXT: &str = "NonEditableKeymapContext";
|
||||
@@ -508,8 +502,24 @@ pub fn init(app: &mut AppContext) {
|
||||
.with_context_predicate(text_entry.clone())
|
||||
.with_key_binding("cmdorctrl-/"),
|
||||
EditableBinding::new("editor_view:delete", "Delete", CodeEditorViewAction::Delete)
|
||||
.with_context_predicate(text_entry.clone())
|
||||
.with_context_predicate(
|
||||
text_entry.clone() & !id!("VimNormalMode") & !id!("VimVisualMode"),
|
||||
)
|
||||
.with_key_binding("ctrl-d"),
|
||||
EditableBinding::new(
|
||||
"editor_view:vim_scroll_half_page_down",
|
||||
"Scroll down half a page (vim)",
|
||||
CodeEditorViewAction::ScrollHalfPageDown,
|
||||
)
|
||||
.with_context_predicate(text_entry.clone() & (id!("VimNormalMode") | id!("VimVisualMode")))
|
||||
.with_key_binding("ctrl-d"),
|
||||
EditableBinding::new(
|
||||
"editor_view:vim_scroll_half_page_up",
|
||||
"Scroll up half a page (vim)",
|
||||
CodeEditorViewAction::ScrollHalfPageUp,
|
||||
)
|
||||
.with_context_predicate(text_entry.clone() & (id!("VimNormalMode") | id!("VimVisualMode")))
|
||||
.with_key_binding("ctrl-u"),
|
||||
EditableBinding::new(
|
||||
"editor_view:cut_word_left",
|
||||
"Cut word left",
|
||||
@@ -616,6 +626,8 @@ pub enum CodeEditorViewAction {
|
||||
ToggleComment,
|
||||
ScrollVertical(Pixels),
|
||||
ScrollHorizontal(Pixels),
|
||||
ScrollHalfPageDown,
|
||||
ScrollHalfPageUp,
|
||||
SelectUp,
|
||||
SelectDown,
|
||||
SelectLeft,
|
||||
@@ -753,6 +765,8 @@ impl CodeEditorViewAction {
|
||||
Self::WindowsCtrlC => true,
|
||||
Self::ScrollVertical(_)
|
||||
| Self::ScrollHorizontal(_)
|
||||
| Self::ScrollHalfPageDown
|
||||
| Self::ScrollHalfPageUp
|
||||
| Self::SelectUp
|
||||
| Self::SelectDown
|
||||
| Self::SelectLeft
|
||||
@@ -867,7 +881,7 @@ impl TypedActionView for CodeEditorView {
|
||||
match self.vim_mode(ctx) {
|
||||
Some(VimMode::Visual(_)) => {
|
||||
// In Vim Visual mode, if we get a ToggleComment request via the keyboard
|
||||
// shorcut (cmd+/), simulate `gc` to the VimModel so that we correctly
|
||||
// shortcut (cmd+/), simulate `gc` to the VimModel so that we correctly
|
||||
// calculate the current visual selections, apply the toggle, and exit to
|
||||
// normal mode.
|
||||
self.vim_user_insert("gc", ctx);
|
||||
@@ -889,6 +903,12 @@ impl TypedActionView for CodeEditorView {
|
||||
render_state.scroll_horizontal(*delta, ctx);
|
||||
})
|
||||
}),
|
||||
ScrollHalfPageDown => {
|
||||
self.vim_keystroke(&Keystroke::parse("ctrl-d").expect("ctrl-d parses"), ctx)
|
||||
}
|
||||
ScrollHalfPageUp => {
|
||||
self.vim_keystroke(&Keystroke::parse("ctrl-u").expect("ctrl-u parses"), ctx)
|
||||
}
|
||||
SelectUp => self.model.update(ctx, |model, ctx| {
|
||||
model.select_up(ctx);
|
||||
}),
|
||||
@@ -1067,8 +1087,6 @@ impl TypedActionView for CodeEditorView {
|
||||
}
|
||||
RevertDiffHunk { line_range } => {
|
||||
if FeatureFlag::RevertDiffHunk.is_enabled() {
|
||||
send_telemetry_from_ctx!(CodeReviewTelemetryEvent::RevertHunkClicked, ctx);
|
||||
|
||||
// Convert line range to diff hunk index and revert it
|
||||
let hunk_index = self
|
||||
.model
|
||||
@@ -1093,6 +1111,7 @@ impl TypedActionView for CodeEditorView {
|
||||
self.model.update(ctx, |model: &mut CodeEditorModel, ctx| {
|
||||
model.open_comment_line(line_info, ctx);
|
||||
});
|
||||
ctx.emit(CodeEditorEvent::CommentEditorOpened);
|
||||
|
||||
ctx.focus(&self.active_comment_editor);
|
||||
ctx.notify();
|
||||
|
||||
Reference in New Issue
Block a user