Skip to main content

Module show_document

Module show_document 

Source
Expand description

Server-initiated window/showDocument plumbing (4.4.b; BC.8c reshape).

Spec (LSP §3.16): the server asks the client to open a URI. The URI can be:

  • A file:// URI – the editor opens it in a buffer.
  • An http:// / https:// URI – the editor delegates to the OS browser when external == true.
  • Any other scheme – best-effort; a server that asks the client to open a non-file, non-web URI without external gets success: false.

Optional fields:

  • external: bool – prefer the OS handler over an in-buffer open. Servers usually set this for http* URIs.
  • take_focus: bool – give the new buffer / window focus.
  • selection: Range – after opening, place the cursor.

BC.8c (2026-06-24): reshaped onto the generic inbound primitive. The bespoke ShowDocumentBus (an mpsc sender with no wake, drained by a host Editor::drain_inbound_show_documents method that itself ran do_edit) is gone. The supervisor now holds an InboundBus<InboundShowDocument> ([lattice_mode::inbound]) whose send wakes the editor so a server-initiated request is answered off-keystroke, and whose per-tick drain runs the mode-owned make_handler below.

Unlike the configuration handler (a pure read), this handler maps each request to a host-applied open [Effect] and resolves the oneshot optimistically (success: true once the request maps to a valid open; false on a non-file / malformed URI). The open effects ([Effect::OpenExternalUri], [Effect::OpenBufferAtColumn]) are host-applied in Editor::handle_effect – they MUST run host-side because this bus drains off-keystroke through the generic inbound tick-callback, where peer-applied effects (OpenBuffer / OpenBufferAt) are not forwarded. The Effect-boundary layering holds: the handler emits generic effects + resolves its own oneshot; no lsp_types crosses into lattice-grammar.

Structs§

InboundShowDocument
One server-initiated window/showDocument request, ferried from the LSP actor to the editor’s per-tick drain.
ShowDocumentOutcome
Result the handler reports back to the actor’s response task. Mirrors ShowDocumentResult.

Functions§

make_handler
BC.8c: the mode-owned handler for server-initiated window/showDocument, registered via boot.inbound::<…>().

Type Aliases§

ShowDocumentBus
The bus the supervisor fans out to each actor – the generic inbound primitive specialised to the show-document payload. send wakes the editor; the per-tick drain runs make_handler. (Was the bespoke ShowDocumentBus struct before BC.8c.)