Editor docs (#4097)

Release Notes:

- N/A

---------

Co-authored-by: Kirill <kirill@zed.dev>
This commit is contained in:
Piotr Osiewicz 2024-01-18 00:48:37 +01:00 committed by GitHub
parent 647b08b101
commit 6cbc49e5f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 507 additions and 376 deletions

View file

@ -1,5 +1,5 @@
use command_palette::CommandInterceptResult;
use editor::{SortLinesCaseInsensitive, SortLinesCaseSensitive};
use editor::actions::{SortLinesCaseInsensitive, SortLinesCaseSensitive};
use gpui::{impl_actions, Action, AppContext, ViewContext};
use serde_derive::Deserialize;
use workspace::{SaveIntent, Workspace};
@ -204,25 +204,31 @@ pub fn command_interceptor(mut query: &str, _: &AppContext) -> Option<CommandInt
// quickfix / loclist (merged together for now)
"cl" | "cli" | "clis" | "clist" => ("clist", diagnostics::Deploy.boxed_clone()),
"cc" => ("cc", editor::Hover.boxed_clone()),
"ll" => ("ll", editor::Hover.boxed_clone()),
"cn" | "cne" | "cnex" | "cnext" => ("cnext", editor::GoToDiagnostic.boxed_clone()),
"lne" | "lnex" | "lnext" => ("cnext", editor::GoToDiagnostic.boxed_clone()),
"cc" => ("cc", editor::actions::Hover.boxed_clone()),
"ll" => ("ll", editor::actions::Hover.boxed_clone()),
"cn" | "cne" | "cnex" | "cnext" => ("cnext", editor::actions::GoToDiagnostic.boxed_clone()),
"lne" | "lnex" | "lnext" => ("cnext", editor::actions::GoToDiagnostic.boxed_clone()),
"cpr" | "cpre" | "cprev" | "cprevi" | "cprevio" | "cpreviou" | "cprevious" => {
("cprevious", editor::GoToPrevDiagnostic.boxed_clone())
"cpr" | "cpre" | "cprev" | "cprevi" | "cprevio" | "cpreviou" | "cprevious" => (
"cprevious",
editor::actions::GoToPrevDiagnostic.boxed_clone(),
),
"cN" | "cNe" | "cNex" | "cNext" => {
("cNext", editor::actions::GoToPrevDiagnostic.boxed_clone())
}
"cN" | "cNe" | "cNex" | "cNext" => ("cNext", editor::GoToPrevDiagnostic.boxed_clone()),
"lp" | "lpr" | "lpre" | "lprev" | "lprevi" | "lprevio" | "lpreviou" | "lprevious" => {
("lprevious", editor::GoToPrevDiagnostic.boxed_clone())
"lp" | "lpr" | "lpre" | "lprev" | "lprevi" | "lprevio" | "lpreviou" | "lprevious" => (
"lprevious",
editor::actions::GoToPrevDiagnostic.boxed_clone(),
),
"lN" | "lNe" | "lNex" | "lNext" => {
("lNext", editor::actions::GoToPrevDiagnostic.boxed_clone())
}
"lN" | "lNe" | "lNex" | "lNext" => ("lNext", editor::GoToPrevDiagnostic.boxed_clone()),
// modify the buffer (should accept [range])
"j" | "jo" | "joi" | "join" => ("join", JoinLines.boxed_clone()),
"d" | "de" | "del" | "dele" | "delet" | "delete" | "dl" | "dell" | "delel" | "deletl"
| "deletel" | "dp" | "dep" | "delp" | "delep" | "deletp" | "deletep" => {
("delete", editor::DeleteLine.boxed_clone())
("delete", editor::actions::DeleteLine.boxed_clone())
}
"sor" | "sor " | "sort" | "sort " => ("sort", SortLinesCaseSensitive.boxed_clone()),
"sor i" | "sort i" => ("sort i", SortLinesCaseInsensitive.boxed_clone()),

View file

@ -1,5 +1,5 @@
use crate::{normal::repeat, state::Mode, Vim};
use editor::{scroll::autoscroll::Autoscroll, Bias};
use editor::{scroll::Autoscroll, Bias};
use gpui::{actions, Action, ViewContext};
use language::SelectionGoal;
use workspace::Workspace;

View file

@ -1,11 +1,10 @@
use editor::{
char_kind,
display_map::{DisplaySnapshot, FoldPoint, ToDisplayPoint},
movement::{self, find_boundary, find_preceding_boundary, FindRange, TextLayoutDetails},
Bias, CharKind, DisplayPoint, ToOffset,
Bias, DisplayPoint, ToOffset,
};
use gpui::{actions, impl_actions, px, ViewContext, WindowContext};
use language::{Point, Selection, SelectionGoal};
use language::{char_kind, CharKind, Point, Selection, SelectionGoal};
use serde::Deserialize;
use workspace::Workspace;

View file

@ -18,7 +18,7 @@ use crate::{
Vim,
};
use collections::HashSet;
use editor::scroll::autoscroll::Autoscroll;
use editor::scroll::Autoscroll;
use editor::{Bias, DisplayPoint};
use gpui::{actions, ViewContext, WindowContext};
use language::SelectionGoal;

View file

@ -1,4 +1,4 @@
use editor::scroll::autoscroll::Autoscroll;
use editor::scroll::Autoscroll;
use gpui::ViewContext;
use language::{Bias, Point};
use workspace::Workspace;

View file

@ -1,13 +1,12 @@
use crate::{motion::Motion, object::Object, state::Mode, utils::copy_selections_content, Vim};
use editor::{
char_kind,
display_map::DisplaySnapshot,
movement::{self, FindRange, TextLayoutDetails},
scroll::autoscroll::Autoscroll,
CharKind, DisplayPoint,
scroll::Autoscroll,
DisplayPoint,
};
use gpui::WindowContext;
use language::Selection;
use language::{char_kind, CharKind, Selection};
pub fn change_motion(vim: &mut Vim, motion: Motion, times: Option<usize>, cx: &mut WindowContext) {
// Some motions ignore failure when switching to normal mode

View file

@ -1,6 +1,6 @@
use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim};
use collections::{HashMap, HashSet};
use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, Bias};
use editor::{display_map::ToDisplayPoint, scroll::Autoscroll, Bias};
use gpui::WindowContext;
use language::Point;

View file

@ -1,6 +1,6 @@
use std::ops::Range;
use editor::{scroll::autoscroll::Autoscroll, MultiBufferSnapshot, ToOffset, ToPoint};
use editor::{scroll::Autoscroll, MultiBufferSnapshot, ToOffset, ToPoint};
use gpui::{impl_actions, ViewContext, WindowContext};
use language::{Bias, Point};
use serde::Deserialize;

View file

@ -1,8 +1,7 @@
use std::{borrow::Cow, cmp};
use editor::{
display_map::ToDisplayPoint, movement, scroll::autoscroll::Autoscroll, ClipboardSelection,
DisplayPoint,
display_map::ToDisplayPoint, movement, scroll::Autoscroll, ClipboardSelection, DisplayPoint,
};
use gpui::{impl_actions, ViewContext};
use language::{Bias, SelectionGoal};

View file

@ -12,7 +12,7 @@ actions!(vim, [Repeat, EndRepeat]);
fn should_replay(action: &Box<dyn Action>) -> bool {
// skip so that we don't leave the character palette open
if editor::ShowCharacterPalette.partial_eq(&**action) {
if editor::actions::ShowCharacterPalette.partial_eq(&**action) {
return false;
}
true

View file

@ -1,7 +1,7 @@
use crate::Vim;
use editor::{
display_map::ToDisplayPoint,
scroll::{scroll_amount::ScrollAmount, VERTICAL_SCROLL_MARGIN},
scroll::{ScrollAmount, VERTICAL_SCROLL_MARGIN},
DisplayPoint, Editor,
};
use gpui::{actions, ViewContext};

View file

@ -1,13 +1,12 @@
use std::ops::Range;
use editor::{
char_kind,
display_map::{DisplaySnapshot, ToDisplayPoint},
movement::{self, FindRange},
Bias, CharKind, DisplayPoint,
Bias, DisplayPoint,
};
use gpui::{actions, impl_actions, ViewContext, WindowContext};
use language::Selection;
use language::{char_kind, CharKind, Selection};
use serde::Deserialize;
use workspace::Workspace;

View file

@ -5,7 +5,7 @@ use collections::HashMap;
use editor::{
display_map::{DisplaySnapshot, ToDisplayPoint},
movement,
scroll::autoscroll::Autoscroll,
scroll::Autoscroll,
Bias, DisplayPoint, Editor,
};
use gpui::{actions, ViewContext, WindowContext};