Skip to content

Commit

Permalink
remove shell_replace_with_output feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Axlefublr committed Nov 17, 2024
1 parent 404e6a0 commit 7f5a122
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ In command mode (and other tab-completable prompts), <kbd>alt+;</kbd> acts the s

In prompts (command mode, pickers, etc), <kbd>alt+,</kbd> moves you to the start of the line and <kbd>alt+.</kbd> to the end, like <kbd>ctrl+a</kbd> and <kbd>ctrl+e</kbd> also do.

`shell_replace_with_output` mappable action, that acts like `shell_pipe`, but doesn't pipe the selections into the command. So, just execute a command and replace selections with the output.

`:random` command with aliases `:rnd`, `:rng` that randomizes your selections.

`whichkey` option in the `[editor]` section can be set to `true` (default) or `false`. \
Expand Down Expand Up @@ -102,7 +100,7 @@ The `insert-final-newline` option now only inserts newline if the file is not em

### Command expansions

Supported in: `shell_pipe`, `shell_pipe_to`, `shell_insert_output`, `shell_append_output`, `shell_replace_with_output` and **all** `:command`s. I'm not yet sure if the latter is a good idea, but feel free to `:cd %p` if you wish /j.
Supported in: `shell_pipe`, `shell_pipe_to`, `shell_insert_output`, `shell_append_output` and **all** `:command`s. I'm not yet sure if the latter is a good idea, but feel free to `:cd %p` if you wish /j.

Example usage: `:sh echo %p`.

Expand Down
8 changes: 2 additions & 6 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ impl MappableCommand {
harp_register_set, "Set a register harp from default register",
harp_command_get, "Execute command harp",
harp_command_set, "Set a command harp from register :",
shell_replace_with_output, "Replace selections with the output of a shell command",
);
}

Expand Down Expand Up @@ -5750,7 +5749,6 @@ enum ShellBehavior {
Ignore,
Insert,
Append,
JustReplace, // fork
}

fn shell_pipe(cx: &mut Context) {
Expand Down Expand Up @@ -5888,7 +5886,7 @@ async fn shell_impl_async(
fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
let pipe = match behavior {
ShellBehavior::Replace | ShellBehavior::Ignore => true,
ShellBehavior::Insert | ShellBehavior::Append | ShellBehavior::JustReplace => false,
ShellBehavior::Insert | ShellBehavior::Append => false,
};

let config = cx.editor.config();
Expand Down Expand Up @@ -5931,9 +5929,7 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
let output_len = output.chars().count();

let (from, to, deleted_len) = match behavior {
ShellBehavior::Replace | ShellBehavior::JustReplace => {
(range.from(), range.to(), range.len())
}
ShellBehavior::Replace => (range.from(), range.to(), range.len()),
ShellBehavior::Insert => (range.from(), range.from(), 0),
ShellBehavior::Append => (range.to(), range.to(), 0),
_ => (range.from(), range.from(), 0),
Expand Down
10 changes: 1 addition & 9 deletions helix-term/src/commands/forkcommands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
commands::{typed, ShellBehavior},
commands::typed,
compositor,
ui::{self, PromptEvent},
};
Expand Down Expand Up @@ -754,14 +754,6 @@ pub fn harp_command_set(cx: &mut Context) {
)
}

pub fn shell_replace_with_output(cx: &mut Context) {
super::shell_prompt(
cx,
"replace-with-output:".into(),
ShellBehavior::JustReplace,
);
}

pub fn get_git_repo_root() -> Option<String> {
let output = std::process::Command::new("git")
.arg("rev-parse")
Expand Down

0 comments on commit 7f5a122

Please sign in to comment.