Repository: helix-editor/helix
File: helix-term/src/commands.rs (Rust)

Code before:
            range.from(),
            graphemes::next_grapheme_boundary(doc.text().slice(..), range.to()),
        )
    });
    doc.set_selection(view.id, selection);
}

fn file_picker(cx: &mut Context) {
    // We don't specify language markers, root will be the root of the current
    // git repo or the current dir if we're not in a repo
    let root = find_root(None, &[]);
    let picker = ui::file_picker(root, &cx.editor.config());
    cx.push_layer(Box::new(overlayed(picker)));
}

fn file_picker_in_current_buffer_directory(cx: &mut Context) {
    let doc = doc!(cx.editor);

    let doc_dir = match doc
        .path()
        .and_then(|path| path.parent().map(|path| path.to_path_buf()))
    {
        Some(path) => path,
        None => {
            cx.editor
                .set_error("current document has no path or parent");
            return;
        }
    };

    let picker = ui::file_picker(doc_dir, &cx.editor.config());
    cx.push_layer(Box::new(overlayed(picker)));
}
fn file_picker_in_current_directory(cx: &mut Context) {
    let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./"));
    let picker = ui::file_picker(cwd, &cx.editor.config());
    cx.push_layer(Box::new(overlayed(picker)));
}

fn buffer_picker(cx: &mut Context) {
    let current = view!(cx.editor).doc;

    struct BufferMeta {
        id: DocumentId,
        path: Option<PathBuf>,
        is_modified: bool,
        is_current: bool,
    }

    impl ui::menu::Item for BufferMeta {
        type Data = ();

Review comment (suggestion):
```suggestion
                .set_error("current buffer has no path or parent");
```

Code after:
    let end = text.len_chars();
    let last_range = doc
        .selection(view.id)
        .iter()
        .last()
        .expect("selection should always have at least one range");
    if !last_range.is_empty() && last_range.to() == end {
        let transaction = Transaction::change(
            doc.text(),
            [(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),
        );
        apply_transaction(&transaction, doc, view);
    }

    let selection = doc.selection(view.id).clone().transform(|range| {
        Range::new(
            range.from(),
            graphemes::next_grapheme_boundary(doc.text().slice(..), range.to()),
        )
    });
    doc.set_selection(view.id, selection);
}

fn file_picker(cx: &mut Context) {
    // We don't specify language markers, root will be the root of the current
    // git repo or the current dir if we're not in a repo
    let root = find_root(None, &[]);
    let picker = ui::file_picker(root, &cx.editor.config());
    cx.push_layer(Box::new(overlayed(picker)));
}

fn file_picker_in_current_buffer_directory(cx: &mut Context) {
    let doc_dir = doc!(cx.editor)
        .path()
        .and_then(|path| path.parent().map(|path| path.to_path_buf()));

    let path = match doc_dir {
        Some(path) => path,
        None => {
            cx.editor.set_error("current buffer has no path or parent");
            return;
        }
    };

    let picker = ui::file_picker(path, &cx.editor.config());
    cx.push_layer(Box::new(overlayed(picker)));
}
fn file_picker_in_current_directory(cx: &mut Context) {
    let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./"));
    let picker = ui::file_picker(cwd, &cx.editor.config());
    cx.push_layer(Box::new(overlayed(picker)));