Repository: lapce/lapce
File: lapce-ui/src/terminal.rs (Rust)

Code before:
                self.request_focus(ctx, data);
                let terminal = data.terminal.terminals.get(&self.term_id).unwrap();
                let term = &mut terminal.raw.lock().term;
                if mouse_event.button.is_right() {
                    let mut clipboard = SystemClipboard {};
                    match term.selection_to_string() {
                        Some(selection) => {
                            clipboard.put_string(selection);
                            term.selection = None;
                        }
                        None => match clipboard.get_string() {
                            Some(string) => {
                                terminal.proxy.proxy_rpc.terminal_write(
                                    terminal.term_id,
                                    string.as_str(),
                                );
                                term.scroll_display(Scroll::Bottom);
                            }
                            None => {}
                        },
                    }
                } else {
                    term.selection = None;
                    if self.prev_click != None
                        && (now - self.prev_click.unwrap()).as_millis()
                            < DOUBLE_CLICK_TIMEOUT
                    {
                        self.select(term, mouse_event, SelectionType::Semantic);
                    }
                    self.prev_click = Some(now);
                }
            }
            Event::MouseMove(mouse_event) => {
                if mouse_event.buttons.has_left() {
                    let term = &mut data
                        .terminal
                        .terminals
                        .get(&self.term_id)
                        .unwrap()
                        .raw
                        .lock()
                        .term;
                    self.select(term, mouse_event, SelectionType::Simple);
                    ctx.request_paint();
                }
            }
            Event::Wheel(wheel_event) => {
                data.terminal
                    .terminals
                    .get(&self.term_id)
                    .unwrap()

Review comment (suggestion):
You can use ```mouse_event.count``` to know if it's a double click, which should be easier. 

Code after:
                    match term.selection_to_string() {
                        Some(selection) => {
                            clipboard.put_string(selection);
                            term.selection = None;
                        }
                        None => match clipboard.get_string() {
                            Some(string) => {
                                terminal.proxy.proxy_rpc.terminal_write(
                                    terminal.term_id,
                                    string.as_str(),
                                );
                                term.scroll_display(Scroll::Bottom);
                            }
                            None => {}
                        },
                    }
                } else if mouse_event.button.is_left() {
                    match mouse_event.count {
                        2 => self.select(term, mouse_event, SelectionType::Semantic),
                        _ => {
                            term.selection = None;
                            if mouse_event.count == 3 {
                                self.select(term, mouse_event, SelectionType::Lines);
                            }
                        }
                    }
                }
            }
            Event::MouseMove(mouse_event) => {
                if mouse_event.buttons.has_left() {
                    let term = &mut data
                        .terminal
                        .terminals
                        .get(&self.term_id)
                        .unwrap()
                        .raw
                        .lock()
                        .term;
                    self.select(term, mouse_event, SelectionType::Simple);
                    ctx.request_paint();
                }
            }
            Event::Wheel(wheel_event) => {
                data.terminal
                    .terminals
                    .get(&self.term_id)
                    .unwrap()
                    .wheel_scroll(wheel_event.wheel_delta.y);
                ctx.request_paint();
            }
            Event::KeyDown(key_event) => {