mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-04 19:37:54 +03:00
parent
0b9701e899
commit
d4ade40983
4 changed files with 18 additions and 18 deletions
|
@ -100,9 +100,9 @@
|
||||||
| `file_picker` | Open file picker | normal: `` <space>f ``, select: `` <space>f `` |
|
| `file_picker` | Open file picker | normal: `` <space>f ``, select: `` <space>f `` |
|
||||||
| `file_picker_in_current_buffer_directory` | Open file picker at current buffer's directory | |
|
| `file_picker_in_current_buffer_directory` | Open file picker at current buffer's directory | |
|
||||||
| `file_picker_in_current_directory` | Open file picker at current working directory | normal: `` <space>F ``, select: `` <space>F `` |
|
| `file_picker_in_current_directory` | Open file picker at current working directory | normal: `` <space>F ``, select: `` <space>F `` |
|
||||||
| `file_browser` | Open file browser in workspace root | normal: `` <space>e ``, select: `` <space>e `` |
|
| `file_explorer` | Open file explorer in workspace root | normal: `` <space>e ``, select: `` <space>e `` |
|
||||||
| `file_browser_in_current_buffer_directory` | Open file browser at current buffer's directory | normal: `` <space>E ``, select: `` <space>E `` |
|
| `file_explorer_in_current_buffer_directory` | Open file explorer at current buffer's directory | normal: `` <space>E ``, select: `` <space>E `` |
|
||||||
| `file_browser_in_current_directory` | Open file browser at current working directory | |
|
| `file_explorer_in_current_directory` | Open file explorer at current working directory | |
|
||||||
| `code_action` | Perform code action | normal: `` <space>a ``, select: `` <space>a `` |
|
| `code_action` | Perform code action | normal: `` <space>a ``, select: `` <space>a `` |
|
||||||
| `buffer_picker` | Open buffer picker | normal: `` <space>b ``, select: `` <space>b `` |
|
| `buffer_picker` | Open buffer picker | normal: `` <space>b ``, select: `` <space>b `` |
|
||||||
| `jumplist_picker` | Open jumplist picker | normal: `` <space>j ``, select: `` <space>j `` |
|
| `jumplist_picker` | Open jumplist picker | normal: `` <space>j ``, select: `` <space>j `` |
|
||||||
|
|
|
@ -393,9 +393,9 @@ impl MappableCommand {
|
||||||
file_picker, "Open file picker",
|
file_picker, "Open file picker",
|
||||||
file_picker_in_current_buffer_directory, "Open file picker at current buffer's directory",
|
file_picker_in_current_buffer_directory, "Open file picker at current buffer's directory",
|
||||||
file_picker_in_current_directory, "Open file picker at current working directory",
|
file_picker_in_current_directory, "Open file picker at current working directory",
|
||||||
file_browser, "Open file browser in workspace root",
|
file_explorer, "Open file explorer in workspace root",
|
||||||
file_browser_in_current_buffer_directory, "Open file browser at current buffer's directory",
|
file_explorer_in_current_buffer_directory, "Open file explorer at current buffer's directory",
|
||||||
file_browser_in_current_directory, "Open file browser at current working directory",
|
file_explorer_in_current_directory, "Open file explorer at current working directory",
|
||||||
code_action, "Perform code action",
|
code_action, "Perform code action",
|
||||||
buffer_picker, "Open buffer picker",
|
buffer_picker, "Open buffer picker",
|
||||||
jumplist_picker, "Open jumplist picker",
|
jumplist_picker, "Open jumplist picker",
|
||||||
|
@ -2995,19 +2995,19 @@ fn file_picker_in_current_directory(cx: &mut Context) {
|
||||||
cx.push_layer(Box::new(overlaid(picker)));
|
cx.push_layer(Box::new(overlaid(picker)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_browser(cx: &mut Context) {
|
fn file_explorer(cx: &mut Context) {
|
||||||
let root = find_workspace().0;
|
let root = find_workspace().0;
|
||||||
if !root.exists() {
|
if !root.exists() {
|
||||||
cx.editor.set_error("Workspace directory does not exist");
|
cx.editor.set_error("Workspace directory does not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(picker) = ui::file_browser(root, cx.editor) {
|
if let Ok(picker) = ui::file_explorer(root, cx.editor) {
|
||||||
cx.push_layer(Box::new(overlaid(picker)));
|
cx.push_layer(Box::new(overlaid(picker)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_browser_in_current_buffer_directory(cx: &mut Context) {
|
fn file_explorer_in_current_buffer_directory(cx: &mut Context) {
|
||||||
let doc_dir = doc!(cx.editor)
|
let doc_dir = doc!(cx.editor)
|
||||||
.path()
|
.path()
|
||||||
.and_then(|path| path.parent().map(|path| path.to_path_buf()));
|
.and_then(|path| path.parent().map(|path| path.to_path_buf()));
|
||||||
|
@ -3023,18 +3023,18 @@ fn file_browser_in_current_buffer_directory(cx: &mut Context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cx.editor.set_error(
|
cx.editor.set_error(
|
||||||
"Current buffer has no parent, opening file browser in current working directory",
|
"Current buffer has no parent, opening file explorer in current working directory",
|
||||||
);
|
);
|
||||||
cwd
|
cwd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(picker) = ui::file_browser(path, cx.editor) {
|
if let Ok(picker) = ui::file_explorer(path, cx.editor) {
|
||||||
cx.push_layer(Box::new(overlaid(picker)));
|
cx.push_layer(Box::new(overlaid(picker)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_browser_in_current_directory(cx: &mut Context) {
|
fn file_explorer_in_current_directory(cx: &mut Context) {
|
||||||
let cwd = helix_stdx::env::current_working_dir();
|
let cwd = helix_stdx::env::current_working_dir();
|
||||||
if !cwd.exists() {
|
if !cwd.exists() {
|
||||||
cx.editor
|
cx.editor
|
||||||
|
@ -3042,7 +3042,7 @@ fn file_browser_in_current_directory(cx: &mut Context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(picker) = ui::file_browser(cwd, cx.editor) {
|
if let Ok(picker) = ui::file_explorer(cwd, cx.editor) {
|
||||||
cx.push_layer(Box::new(overlaid(picker)));
|
cx.push_layer(Box::new(overlaid(picker)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,8 +222,8 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
|
||||||
"space" => { "Space"
|
"space" => { "Space"
|
||||||
"f" => file_picker,
|
"f" => file_picker,
|
||||||
"F" => file_picker_in_current_directory,
|
"F" => file_picker_in_current_directory,
|
||||||
"e" => file_browser,
|
"e" => file_explorer,
|
||||||
"E" => file_browser_in_current_buffer_directory,
|
"E" => file_explorer_in_current_buffer_directory,
|
||||||
"b" => buffer_picker,
|
"b" => buffer_picker,
|
||||||
"j" => jumplist_picker,
|
"j" => jumplist_picker,
|
||||||
"s" => symbol_picker,
|
"s" => symbol_picker,
|
||||||
|
|
|
@ -279,9 +279,9 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
|
||||||
picker
|
picker
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileBrowser = Picker<(PathBuf, bool), (PathBuf, Style)>;
|
type FileExplorer = Picker<(PathBuf, bool), (PathBuf, Style)>;
|
||||||
|
|
||||||
pub fn file_browser(root: PathBuf, editor: &Editor) -> Result<FileBrowser, std::io::Error> {
|
pub fn file_explorer(root: PathBuf, editor: &Editor) -> Result<FileExplorer, std::io::Error> {
|
||||||
let directory_style = editor.theme.get("ui.text.directory");
|
let directory_style = editor.theme.get("ui.text.directory");
|
||||||
let directory_content = directory_content(&root)?;
|
let directory_content = directory_content(&root)?;
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ pub fn file_browser(root: PathBuf, editor: &Editor) -> Result<FileBrowser, std::
|
||||||
let callback = Box::pin(async move {
|
let callback = Box::pin(async move {
|
||||||
let call: Callback =
|
let call: Callback =
|
||||||
Callback::EditorCompositor(Box::new(move |editor, compositor| {
|
Callback::EditorCompositor(Box::new(move |editor, compositor| {
|
||||||
if let Ok(picker) = file_browser(new_root, editor) {
|
if let Ok(picker) = file_explorer(new_root, editor) {
|
||||||
compositor.push(Box::new(overlay::overlaid(picker)));
|
compositor.push(Box::new(overlay::overlaid(picker)));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue