pub fn view_workdir(
ctx: &ModeContext,
buffer: BufferId,
handle: &Arc<dyn Document>,
) -> Option<PathBuf>Expand description
MR.3: the repository a magit view acts on, read at activation — the
other end of what open_repo_view wrote.
Every view’s on_activate asks exactly this, and asks it the same
way: the record under this buffer’s name, else the working directory.
The fallback is not defensive padding — a magit buffer reopened by
:b after a restart has a name and no record, and the working
directory is the answer magit gave for that buffer before MR.2.
Also indexes the document, so closing the buffer drops the record. Here rather than at the trigger because this is the first moment the document exists — and in the same helper as the read so a new view cannot pick up one half and forget the other.