Repository: bevyengine/bevy
File: tools/export-content/src/app.rs (Rust)

Code before:
                    },
                    KeyCode::Down => {
                        if key.modifiers.contains(KeyModifiers::SHIFT) {
                            if let Some(index) = mode_state.selected() {
                                if index < mode_entries.len() - 1 {
                                    mode_entries.swap(index, index + 1);
                                }
                            }
                        }
                        mode_state.select_next();
                    }
                    KeyCode::Up => {
                        if key.modifiers.contains(KeyModifiers::SHIFT) {
                            if let Some(index) = mode_state.selected() {
                                if index > 0 {
                                    mode_entries.swap(index, index - 1);
                                }
                            }
                        }
                        mode_state.select_previous();
                    }
                    KeyCode::Char('+') => {
                        self.text_entry = Some(String::new());
                    }
                    KeyCode::Char('d') => {
                        if let Some(index) = mode_state.selected() {
                            if let Entry::Section { .. } = mode_entries[index] {
                                mode_entries.remove(index);
                            }
                        }
                    }
                    _ => {}
                }
            }
        }

        self.write_output()
    }

    pub fn render(&mut self, frame: &mut Frame) {
        use Constraint::*;

        let page_area = frame.area().inner(Margin::new(1, 1));
        let [header_area, instructions_area, _, block_area, _, typing_area] = Layout::vertical([
            Length(2), // header
            Length(2), // instructions
            Length(1), // gap
            Fill(1),   // blocks
            Length(1), // gap
            Length(2), // text input
        ])

Review comment (suggestion):
ditto
```suggestion
                        if let Some(index) = mode_state.selected()
                            && let Entry::Section { .. } = mode_entries[index]
                        {
```

Code after:
                    },
                    KeyCode::Down => {
                        if key.modifiers.contains(KeyModifiers::SHIFT)
                            && let Some(index) = mode_state.selected()
                            && index < mode_entries.len() - 1
                        {
                            mode_entries.swap(index, index + 1);
                        }
                        mode_state.select_next();
                    }
                    KeyCode::Up => {
                        if key.modifiers.contains(KeyModifiers::SHIFT)
                            && let Some(index) = mode_state.selected()
                            && index > 0
                        {
                            mode_entries.swap(index, index - 1);
                        }
                        mode_state.select_previous();
                    }
                    KeyCode::Char('+') => {
                        self.text_entry = Some(String::new());
                    }
                    KeyCode::Char('d') => {
                        if let Some(index) = mode_state.selected()
                            && let Entry::Section { .. } = mode_entries[index]
                        {
                            mode_entries.remove(index);
                        }
                    }
                    _ => {}
                }
            }
        }

        self.write_output()
    }

    pub fn render(&mut self, frame: &mut Frame) {
        use Constraint::*;

        let page_area = frame.area().inner(Margin::new(1, 1));
        let [header_area, instructions_area, _, block_area, _, typing_area] = Layout::vertical([
            Length(2), // header
            Length(2), // instructions
            Length(1), // gap
            Fill(1),   // blocks
            Length(1), // gap
            Length(2), // text input
        ])
        .areas(page_area);