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

Code before:
        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_view_directory(cx: &mut Context) {
    let (_, doc) = current_ref!(cx.editor);

    let cwd = doc
        .path()
        .and_then(|path| path.parent().map(|path| path.to_path_buf()))
        .unwrap_or_else(|| 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 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,
    }


Review comment (suggestion):
```suggestion
    let doc = doc!(cx.editor);
```

Code after:
// inserts at the end of each selection
fn append_mode(cx: &mut Context) {
    enter_insert_mode(cx);
    let (view, doc) = current!(cx.editor);
    doc.restore_cursor = true;
    let text = doc.text().slice(..);

    // Make sure there's room at the end of the document if the last
    // selection butts up against it.
    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;
        }