diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 1c35fa6bcdd4e80bf503ff2ef5d067f92705f6bd..98a5ff7f4dff503adef18638c9c5b5b766b13d82 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -636,11 +636,30 @@ impl EditorElement { cx.stop_propagation(); } else if end_selection && pending_nonempty_selections { cx.stop_propagation(); - } else if cfg!(target_os = "linux") - && event.button == MouseButton::Middle - && (!text_hitbox.is_hovered(cx) || editor.read_only(cx)) - { - return; + } else if cfg!(target_os = "linux") && event.button == MouseButton::Middle { + if !text_hitbox.is_hovered(cx) || editor.read_only(cx) { + return; + } + + #[cfg(target_os = "linux")] + if EditorSettings::get_global(cx).middle_click_paste { + if let Some(text) = cx.read_from_primary().and_then(|item| item.text()) { + let point_for_position = + position_map.point_for_position(text_hitbox.bounds, event.position); + let position = point_for_position.previous_valid; + + editor.select( + SelectPhase::Begin { + position, + add: false, + click_count: 1, + }, + cx, + ); + editor.insert(&text, cx); + } + cx.stop_propagation() + } } }