Repository: zellij-org/zellij
File: zellij-server/src/panes/terminal_pane.rs (Rust)

Code before:
        // there are some cases in which the terminal state means that input sent to it
        // needs to be adjusted.
        // here we match against those cases - if need be, we adjust the input and if not
        // we send back the original input
        if self.grid.cursor_key_mode {
            match input_bytes.as_slice() {
                LEFT_ARROW => {
                    return AnsiEncoding::Left.as_vec_bytes();
                },
                RIGHT_ARROW => {
                    return AnsiEncoding::Right.as_vec_bytes();
                },
                UP_ARROW => {
                    return AnsiEncoding::Up.as_vec_bytes();
                },
                DOWN_ARROW => {
                    return AnsiEncoding::Down.as_vec_bytes();
                },

                HOME_KEY => {
                    return AnsiEncoding::Home.as_vec_bytes();
                },
                END_KEY => {
                    return AnsiEncoding::End.as_vec_bytes();
                },
                [27, 91, 50, 48, 48, 126] | [27, 91, 50, 48, 49, 126] => {
                    if !self.grid.bracketed_paste_mode {
                        // Zellij itself operates in bracketed paste mode, so the terminal sends these
                        // instructions (bracketed paste start and bracketed paste end respectively)
                        // when pasting input. We only need to make sure not to send them to terminal
                        // panes who do not work in this mode
                        return vec![];
                    }
                },
                _ => {},
            };
        }
        input_bytes
    }
    fn position_and_size(&self) -> PaneGeom {
        self.geom
    }
    fn current_geom(&self) -> PaneGeom {
        self.geom_override.unwrap_or(self.geom)
    }
    fn geom_override(&self) -> Option<PaneGeom> {
        self.geom_override
    }
    fn should_render(&self) -> bool {
        self.grid.should_render
    }

Review comment (refactor):
Do you plan on refactoring this? If not, what about `BRACKETED_PASTE_BEGIN`
and `BRACKETED_PASTE_END` ?


Code after:
        // there are some cases in which the terminal state means that input sent to it
        // needs to be adjusted.
        // here we match against those cases - if need be, we adjust the input and if not
        // we send back the original input
        if self.grid.cursor_key_mode {
            match input_bytes.as_slice() {
                LEFT_ARROW => {
                    return AnsiEncoding::Left.as_vec_bytes();
                },
                RIGHT_ARROW => {
                    return AnsiEncoding::Right.as_vec_bytes();
                },
                UP_ARROW => {
                    return AnsiEncoding::Up.as_vec_bytes();
                },
                DOWN_ARROW => {
                    return AnsiEncoding::Down.as_vec_bytes();
                },

                HOME_KEY => {
                    return AnsiEncoding::Home.as_vec_bytes();
                },
                END_KEY => {
                    return AnsiEncoding::End.as_vec_bytes();
                },
                BRACKETED_PASTE_BEGIN | BRACKETED_PASTE_END => {
                    if !self.grid.bracketed_paste_mode {
                        // Zellij itself operates in bracketed paste mode, so the terminal sends these
                        // instructions (bracketed paste start and bracketed paste end respectively)
                        // when pasting input. We only need to make sure not to send them to terminal
                        // panes who do not work in this mode
                        return vec![];
                    }
                },
                _ => {},
            };
        }
        input_bytes
    }
    fn position_and_size(&self) -> PaneGeom {
        self.geom
    }
    fn current_geom(&self) -> PaneGeom {
        self.geom_override.unwrap_or(self.geom)
    }
    fn geom_override(&self) -> Option<PaneGeom> {
        self.geom_override
    }
    fn should_render(&self) -> bool {
        self.grid.should_render
    }