terminal: Add right-click in terminal to create a new selection if none is present (#29131)

This PR adds functionality to right click in terminal create new
selection if none present. The selection is identical with double click
a text in terminal, plus the logic is moved from the double-click in the
terminal::mouse_down.

Closes #28237 

Release Notes:
- Adds functionality to right click in terminal create new selection if
none present
This commit is contained in:
Ho Chun Lau 2025-04-21 16:39:17 +01:00 committed by GitHub
parent 6d2bdc3bac
commit f8ac6eef75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -1278,6 +1278,11 @@ impl Render for TerminalView {
MouseButton::Right,
cx.listener(|this, event: &MouseDownEvent, window, cx| {
if !this.terminal.read(cx).mouse_mode(event.modifiers.shift) {
if this.terminal.read(cx).last_content.selection.is_none() {
this.terminal.update(cx, |terminal, _| {
terminal.select_word_at_event_position(event);
});
};
this.deploy_context_menu(event.position, window, cx);
cx.notify();
}