-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trim final newline from :pipe
output
#10912
Comments
#8366 already implements a command to trim, so you could just pipe and execute that if/when it is merged |
That’s a possible solution, but it means that the vast majority of the time you pipe to another command you’ll have to I’d also be open to it only trimming a single trailing newline too. But as it is, stuff like piping to |
:pipe
output
I've played around with this and it seems like it is indeed a bit more intuitive when the newline is trimmed(perhaps a placebo). I can make a pr so that it can be tested. I'm unsure if I implemented the change in full completeness, as the exiting logic is kind of hard to understand how any other branch could yield a result, and so only changed the one area I thought could, and it appears to work fine. let output = if let Some(output) = shell_output.as_ref() {
output.clone()
} else {
let fragment = range.slice(text);
match shell_impl(shell, cmd, pipe.then(|| fragment.into())) {
Ok(result) => {
if !pipe {
shell_output = Some(result.clone());
}
- result
+ Tendril::from(result.trim_end())
}
Err(err) => {
cx.editor.set_error(err.to_string());
return;
}
}
}; |
That's the exact change I made in my branch too 😁 I agree, it does feel much nicer to use, don't think it's a placebo. I reckon make a PR with it! |
I want to use
|
/:pipe
more often but it inserts trailing whitespace that the command generated. This limits its usefulness because when I want to run the same command on every selection, everything gets messed up because of the additional whitespace. It's not too much effort to clean it up, but it's annoying and I've never actually wanted the whitespace to be inserted. For reference, this is the way that Vim/NeoVim handle it.My preference would be to have the trailing whitespace trimming on by default, but I'm open to the idea that it could be a new command like
pipe_trim
or something. If it's decided to go ahead with this then I'll implement it.The text was updated successfully, but these errors were encountered: