Preview and apply source actions
Use lsp_code_actions to preview actions for a file. It never writes:
lsp_code_actions({"filePath":"src/index.ts"})lsp_fix is a shortcut for source actions. It defaults to kind: "source.fixAll" and write: false:
lsp_fix({"filePath":"src/index.ts"})Use kind: "source.organizeImports" when that is the intended action.
Apply only a current preview
Section titled “Apply only a current preview”Set write: true only when one unambiguous action is expected. The extension writes only if exactly one action is returned. With zero or multiple actions, it writes no bytes and returns previews. Select a preview with lsp_apply_code_action:
lsp_apply_code_action({"previewId":"<returned-preview-id>"})Previews are tied to the session, server, canonical file, and content hash. Make a new preview if the file changed. The extension rejects stale previews, edits outside the workspace, symlink-boundary escapes, resource operations, overlapping edits, unsupported versions, and oversized edit sets.
Rename follows the same guarded edit path
Section titled “Rename follows the same guarded edit path”Use lsp_prepare_rename to check whether the server accepts a position. lsp_rename then takes filePath, line, character, and newName; it prepares the target again before requesting and validating the workspace edit. It does not consume a previewId.
Multi-file commits lock files in canonical order, use atomic replacement, and report recovery artifacts if rollback cannot complete. Stop editing affected files if that happens; preserve the reported relative artifact names.
Read the security limits and troubleshooting guidance before automating writes.