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

Code before:
        })
    }

    pub fn run<B: Backend>(mut self, terminal: &mut Terminal<B>) -> Result<()> {
        while !self.exit {
            terminal
                .draw(|frame| self.render(frame))
                .into_diagnostic()?;

            let (mode_state, mode_entries) = match self.mode {
                Mode::ReleaseNotes => (&mut self.release_notes_state, &mut self.release_notes),
                Mode::MigrationGuides => {
                    (&mut self.migration_guide_state, &mut self.migration_guides)
                }
            };

            if let Event::Key(key) = event::read().into_diagnostic()? {
                // If text entry is enabled, capture all input events
                if let Some(text) = &mut self.text_entry {
                    match key.code {
                        KeyCode::Esc => self.text_entry = None,
                        KeyCode::Backspace => {
                            text.pop();
                        }
                        KeyCode::Enter => {
                            if text != "" {
                                if let Some(index) = mode_state.selected() {
                                    mode_entries.insert(
                                        index,
                                        Entry::Section {
                                            title: text.clone(),
                                        },
                                    );
                                }
                            }
                            self.text_entry = None;
                        }
                        KeyCode::Char(c) => text.push(c),
                        _ => {}
                    }

                    continue;
                }

                match key.code {
                    KeyCode::Esc => self.exit = true,
                    KeyCode::Tab => match self.mode {
                        Mode::ReleaseNotes => self.mode = Mode::MigrationGuides,
                        Mode::MigrationGuides => self.mode = Mode::ReleaseNotes,
                    },
                    KeyCode::Down => {

Review comment (suggestion):
Nit: use is_empty and collapse

```suggestion
                            if !text.is_empty()
                                && let Some(index) = mode_state.selected()

```

Code after:
        })
    }

    pub fn run<B: Backend>(mut self, terminal: &mut Terminal<B>) -> Result<()> {
        while !self.exit {
            terminal
                .draw(|frame| self.render(frame))
                .into_diagnostic()?;

            let (mode_state, mode_entries) = match self.mode {
                Mode::ReleaseNotes => (&mut self.release_notes_state, &mut self.release_notes),
                Mode::MigrationGuides => {
                    (&mut self.migration_guide_state, &mut self.migration_guides)
                }
            };

            if let Event::Key(key) = event::read().into_diagnostic()? {
                // If text entry is enabled, capture all input events
                if let Some(text) = &mut self.text_entry {
                    match key.code {
                        KeyCode::Esc => self.text_entry = None,
                        KeyCode::Backspace => {
                            text.pop();
                        }
                        KeyCode::Enter => {
                            if !text.is_empty()
                                && let Some(index) = mode_state.selected()
                            {
                                mode_entries.insert(
                                    index,
                                    Entry::Section {
                                        title: text.clone(),
                                    },
                                );
                            }
                            self.text_entry = None;
                        }
                        KeyCode::Char(c) => text.push(c),
                        _ => {}
                    }

                    continue;
                }

                match key.code {
                    KeyCode::Esc => self.exit = true,
                    KeyCode::Tab => match self.mode {
                        Mode::ReleaseNotes => self.mode = Mode::MigrationGuides,
                        Mode::MigrationGuides => self.mode = Mode::ReleaseNotes,
                    },
                    KeyCode::Down => {