@@ -1034,6 +1034,50 @@ fn reload(
10341034 })
10351035}
10361036
1037+fn reload_all(
1038+ cx: &mut compositor::Context,
1039+ _args: &[Cow<str>],
1040+ event: PromptEvent,
1041+) -> anyhow::Result<()> {
1042+ if event != PromptEvent::Validate {
1043+ return Ok(());
1044+ }
1045+
1046+ let scrolloff = cx.editor.config().scrolloff;
1047+ let view_id = view!(cx.editor).id;
1048+
1049+ let docs_view_ids: Vec<(DocumentId, Vec<ViewId>)> = cx
1050+ .editor
1051+ .documents_mut()
1052+ .map(|doc| {
1053+ let mut view_ids: Vec<_> = doc.selections().keys().cloned().collect();
1054+
1055+ if view_ids.is_empty() {
1056+ doc.ensure_view_init(view_id);
1057+ view_ids.push(view_id);
1058+ };
1059+
1060+ (doc.id(), view_ids)
1061+ })
1062+ .collect();
1063+
1064+ for (doc_id, view_ids) in docs_view_ids {
1065+ let doc = doc_mut!(cx.editor, &doc_id);
1066+
1067+ // Every doc is guaranteed to have at least 1 view at this point.
1068+ let view = view_mut!(cx.editor, view_ids[0]);
1069+ doc.reload(view)?;
1070+
1071+ for view_id in view_ids {
1072+ let view = view_mut!(cx.editor, view_id);
1073+
1074+ view.ensure_cursor_in_view(doc, scrolloff);
1075+ }
1076+ }
1077+
1078+ Ok(())
1079+}
1080+
10371081/// Update the [`Document`] if it has been modified.
10381082fn update(
10391083 cx: &mut compositor::Context,
@@ -2051,6 +2095,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
20512095 fun: reload,
20522096 completer: None,
20532097 },
2098+ TypableCommand {
2099+ name: "reload-all",
2100+ aliases: &[],
2101+ doc: "Discard changes and reload all documents from the source files.",
2102+ fun: reload_all,
2103+ completer: None,
2104+ },
20542105 TypableCommand {
20552106 name: "update",
20562107 aliases: &[],