mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 01:16:18 +04:00
Add default-yank-register option (#11430)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
parent
b92e8abfb3
commit
9e171e7d1d
@ -24,6 +24,7 @@ ### `[editor]` Section
|
|||||||
|--|--|---------|
|
|--|--|---------|
|
||||||
| `scrolloff` | Number of lines of padding around the edge of the screen when scrolling | `5` |
|
| `scrolloff` | Number of lines of padding around the edge of the screen when scrolling | `5` |
|
||||||
| `mouse` | Enable mouse mode | `true` |
|
| `mouse` | Enable mouse mode | `true` |
|
||||||
|
| `default-yank-register` | Default register used for yank/paste | `"` |
|
||||||
| `middle-click-paste` | Middle click paste support | `true` |
|
| `middle-click-paste` | Middle click paste support | `true` |
|
||||||
| `scroll-lines` | Number of lines to scroll per scroll wheel step | `3` |
|
| `scroll-lines` | Number of lines to scroll per scroll wheel step | `3` |
|
||||||
| `shell` | Shell to use when running external commands | Unix: `["sh", "-c"]`<br/>Windows: `["cmd", "/C"]` |
|
| `shell` | Shell to use when running external commands | Unix: `["sh", "-c"]`<br/>Windows: `["cmd", "/C"]` |
|
||||||
|
@ -2735,7 +2735,9 @@ fn delete_selection_impl(cx: &mut Context, op: Operation, yank: YankAction) {
|
|||||||
// yank the selection
|
// yank the selection
|
||||||
let text = doc.text().slice(..);
|
let text = doc.text().slice(..);
|
||||||
let values: Vec<String> = selection.fragments(text).map(Cow::into_owned).collect();
|
let values: Vec<String> = selection.fragments(text).map(Cow::into_owned).collect();
|
||||||
let reg_name = cx.register.unwrap_or('"');
|
let reg_name = cx
|
||||||
|
.register
|
||||||
|
.unwrap_or_else(|| cx.editor.config.load().default_yank_register);
|
||||||
if let Err(err) = cx.editor.registers.write(reg_name, values) {
|
if let Err(err) = cx.editor.registers.write(reg_name, values) {
|
||||||
cx.editor.set_error(err.to_string());
|
cx.editor.set_error(err.to_string());
|
||||||
return;
|
return;
|
||||||
@ -4221,7 +4223,11 @@ fn commit_undo_checkpoint(cx: &mut Context) {
|
|||||||
// Yank / Paste
|
// Yank / Paste
|
||||||
|
|
||||||
fn yank(cx: &mut Context) {
|
fn yank(cx: &mut Context) {
|
||||||
yank_impl(cx.editor, cx.register.unwrap_or('"'));
|
yank_impl(
|
||||||
|
cx.editor,
|
||||||
|
cx.register
|
||||||
|
.unwrap_or(cx.editor.config().default_yank_register),
|
||||||
|
);
|
||||||
exit_select_mode(cx);
|
exit_select_mode(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4282,7 +4288,12 @@ fn yank_joined_impl(editor: &mut Editor, separator: &str, register: char) {
|
|||||||
|
|
||||||
fn yank_joined(cx: &mut Context) {
|
fn yank_joined(cx: &mut Context) {
|
||||||
let separator = doc!(cx.editor).line_ending.as_str();
|
let separator = doc!(cx.editor).line_ending.as_str();
|
||||||
yank_joined_impl(cx.editor, separator, cx.register.unwrap_or('"'));
|
yank_joined_impl(
|
||||||
|
cx.editor,
|
||||||
|
separator,
|
||||||
|
cx.register
|
||||||
|
.unwrap_or(cx.editor.config().default_yank_register),
|
||||||
|
);
|
||||||
exit_select_mode(cx);
|
exit_select_mode(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4442,7 +4453,12 @@ fn paste_primary_clipboard_before(cx: &mut Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn replace_with_yanked(cx: &mut Context) {
|
fn replace_with_yanked(cx: &mut Context) {
|
||||||
replace_with_yanked_impl(cx.editor, cx.register.unwrap_or('"'), cx.count());
|
replace_with_yanked_impl(
|
||||||
|
cx.editor,
|
||||||
|
cx.register
|
||||||
|
.unwrap_or(cx.editor.config().default_yank_register),
|
||||||
|
cx.count(),
|
||||||
|
);
|
||||||
exit_select_mode(cx);
|
exit_select_mode(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4505,7 +4521,8 @@ fn paste(editor: &mut Editor, register: char, pos: Paste, count: usize) {
|
|||||||
fn paste_after(cx: &mut Context) {
|
fn paste_after(cx: &mut Context) {
|
||||||
paste(
|
paste(
|
||||||
cx.editor,
|
cx.editor,
|
||||||
cx.register.unwrap_or('"'),
|
cx.register
|
||||||
|
.unwrap_or(cx.editor.config().default_yank_register),
|
||||||
Paste::After,
|
Paste::After,
|
||||||
cx.count(),
|
cx.count(),
|
||||||
);
|
);
|
||||||
@ -4515,7 +4532,8 @@ fn paste_after(cx: &mut Context) {
|
|||||||
fn paste_before(cx: &mut Context) {
|
fn paste_before(cx: &mut Context) {
|
||||||
paste(
|
paste(
|
||||||
cx.editor,
|
cx.editor,
|
||||||
cx.register.unwrap_or('"'),
|
cx.register
|
||||||
|
.unwrap_or(cx.editor.config().default_yank_register),
|
||||||
Paste::Before,
|
Paste::Before,
|
||||||
cx.count(),
|
cx.count(),
|
||||||
);
|
);
|
||||||
@ -5369,7 +5387,8 @@ fn insert_register(cx: &mut Context) {
|
|||||||
cx.register = Some(ch);
|
cx.register = Some(ch);
|
||||||
paste(
|
paste(
|
||||||
cx.editor,
|
cx.editor,
|
||||||
cx.register.unwrap_or('"'),
|
cx.register
|
||||||
|
.unwrap_or(cx.editor.config().default_yank_register),
|
||||||
Paste::Cursor,
|
Paste::Cursor,
|
||||||
cx.count(),
|
cx.count(),
|
||||||
);
|
);
|
||||||
|
@ -270,6 +270,8 @@ pub struct Config {
|
|||||||
pub auto_completion: bool,
|
pub auto_completion: bool,
|
||||||
/// Automatic formatting on save. Defaults to true.
|
/// Automatic formatting on save. Defaults to true.
|
||||||
pub auto_format: bool,
|
pub auto_format: bool,
|
||||||
|
/// Default register used for yank/paste. Defaults to '"'
|
||||||
|
pub default_yank_register: char,
|
||||||
/// Automatic save on focus lost and/or after delay.
|
/// Automatic save on focus lost and/or after delay.
|
||||||
/// Time delay in milliseconds since last edit after which auto save timer triggers.
|
/// Time delay in milliseconds since last edit after which auto save timer triggers.
|
||||||
/// Time delay defaults to false with 3000ms delay. Focus lost defaults to false.
|
/// Time delay defaults to false with 3000ms delay. Focus lost defaults to false.
|
||||||
@ -951,6 +953,7 @@ fn default() -> Self {
|
|||||||
auto_pairs: AutoPairConfig::default(),
|
auto_pairs: AutoPairConfig::default(),
|
||||||
auto_completion: true,
|
auto_completion: true,
|
||||||
auto_format: true,
|
auto_format: true,
|
||||||
|
default_yank_register: '"',
|
||||||
auto_save: AutoSave::default(),
|
auto_save: AutoSave::default(),
|
||||||
idle_timeout: Duration::from_millis(250),
|
idle_timeout: Duration::from_millis(250),
|
||||||
completion_timeout: Duration::from_millis(250),
|
completion_timeout: Duration::from_millis(250),
|
||||||
|
Loading…
Reference in New Issue
Block a user