@@ -1034,6 +1034,50 @@ fn reload(
1038+ cx: &mut compositor::Context,
1039+ _args: &[Cow<str>],
1040+ event: PromptEvent,
1041+) -> anyhow::Result<()> {
1042+ if event != PromptEvent::Validate {
1046+ let scrolloff = cx.editor.config().scrolloff;
1047+ let view_id = view!(cx.editor).id;
1049+ let docs_view_ids: Vec<(DocumentId, Vec<ViewId>)> = cx
1053+ let mut view_ids: Vec<_> = doc.selections().keys().cloned().collect();
1055+ if view_ids.is_empty() {
1056+ doc.ensure_view_init(view_id);
1057+ view_ids.push(view_id);
1060+ (doc.id(), view_ids)
1064+ for (doc_id, view_ids) in docs_view_ids {
1065+ let doc = doc_mut!(cx.editor, &doc_id);
1067+ // Every doc is guaranteed to have at least 1 view at this point.
1068+ let view = view_mut!(cx.editor, view_ids[0]);
1071+ for view_id in view_ids {
1072+ let view = view_mut!(cx.editor, view_id);
1074+ view.ensure_cursor_in_view(doc, scrolloff);
1037/// Update the [`Document`] if it has been modified.
1081/// Update the [`Document`] if it has been modified.
1038fn update(
1082fn update(
1039 cx: &mut compositor::Context,
1083 cx: &mut compositor::Context,
@@ -2051,6 +2095,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2051 fun: reload,
2095 fun: reload,
2052 completer: None,
2096 completer: None,
2099+ name: "reload-all",
2101+ doc: "Discard changes and reload all documents from the source files.",
2054 TypableCommand {
2105 TypableCommand {
2055 name: "update",
2106 name: "update",
2056 aliases: &[],
2107 aliases: &[],