Skip to content

Commit

Permalink
Merge commit 'refs/pull/9640/head' of https://github.com/helix-editor…
Browse files Browse the repository at this point in the history
  • Loading branch information
postsolar committed Mar 11, 2024
2 parents 772456b + f586557 commit d559a7e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# PRs merged into this branch

[Add `unbind_default_keys` config option #9384](https://github.com/helix-editor/helix/pull/9384)

[Add a simple amp-like jump command #8875](https://github.com/helix-editor/helix/pull/8875)

[Add command expansions `%key{body}` #6979](https://github.com/helix-editor/helix/pull/6979)

[Globbing support in `:open` #9723](https://github.com/helix-editor/helix/pull/9723)

[Pickers "v2" #9647](https://github.com/helix-editor/helix/pull/9647)

[Implement new textobject for indentation level #9843](https://github.com/helix-editor/helix/pull/9843)

[Add a yank diagnostic command #9640](https://github.com/helix-editor/helix/pull/9640)

<div align="center">

<h1>
Expand Down
28 changes: 28 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ impl MappableCommand {
yank_main_selection_to_clipboard, "Yank main selection to clipboard",
yank_joined_to_primary_clipboard, "Join and yank selections to primary clipboard",
yank_main_selection_to_primary_clipboard, "Yank main selection to primary clipboard",
yank_diagnostic, "Yank diagnostic(s) under primary cursor to register, or clipboard by default",
replace_with_yanked, "Replace with yanked text",
replace_selections_with_clipboard, "Replace selections by clipboard content",
replace_selections_with_primary_clipboard, "Replace selections by primary clipboard",
Expand Down Expand Up @@ -5705,6 +5706,33 @@ fn increment_impl(cx: &mut Context, increment_direction: IncrementDirection) {
}
}

fn yank_diagnostic(cx: &mut Context) {
let (view, doc) = current_ref!(cx.editor);
let primary = doc.selection(view.id).primary();

let diag: Vec<_> = doc
.diagnostics()
.iter()
.filter(|d| primary.overlaps(&helix_core::Range::new(d.range.start, d.range.end)))
.map(|d| d.message.clone())
.collect();
let n = diag.len();
if n == 0 {
cx.editor
.set_error("No diagnostics under primary selection");
return;
}

let reg = cx.register.unwrap_or('+');
match cx.editor.registers.write(reg, diag) {
Ok(_) => cx.editor.set_status(format!(
"Yanked {n} diagnostic{} to register {reg}",
if n == 1 { "" } else { "s" }
)),
Err(err) => cx.editor.set_error(err.to_string()),
}
}

fn record_macro(cx: &mut Context) {
if let Some((reg, mut keys)) = cx.editor.macro_recording.take() {
// Remove the keypress which ends the recording
Expand Down

0 comments on commit d559a7e

Please sign in to comment.