Repository navigation
Enable automatic formatting in Interactive input - #1867
Conversation
eitsupi
left a comment
There was a problem hiding this comment.
ChatGPT-assisted review
I think this implementation introduces an unnecessary coupling between Interactive input handling and LanguageService.
InteractiveInputFeatures is owned by LanguageService and directly depends on its LanguageClient, even though formatting is already requested through standard VS Code provider commands.
This conflicts with the separation of responsibilities proposed in #1749.
I suggest moving InteractiveInputFeatures lifecycle management to the Interactive layer and removing its dependency on LanguageClient. Formatting should work with any registered VS Code formatting provider, independently of the built-in language service.
The tests should also avoid making unrelated extension functionality depend on the built-in language server being available.
|
Addressed in eeba0aa.
The test setup now separates provider/extension tests from real Interactive language-server integration. The former run with the built-in language server disabled; only the integration suite waits for a real server. Validation on macOS: 495 provider/extension tests and 59 real R integration tests passed. The six independent-provider formatting tests cover custom triggers, settings, paste ranges and forwarding, cursor/undo behavior, and delayed replies. Build, TypeScript type checking, and lint also passed. |
eitsupi
left a comment
There was a problem hiding this comment.
ChatGPT-assisted follow-up review
One issue remains in InteractiveInputFeatures: formatOnType() treats single-character document changes as typing, including changes caused by paste.
With editor.formatOnType=true and editor.formatOnPaste=false, pasting a trigger character such as ) may still invoke on-type formatting, ignoring the user's paste setting.
Could you suppress on-type formatting for paste operations and add a regression test covering this case?
R Interactive's native input editor omits automatic formatting. Add a single bridge so typing
(1+1)formats it to(1 + 1)witheditor.formatOnType, and pasted ranges respecteditor.formatOnPaste.InteractiveManagerowns the bridge, which requests edits from VS Code's registered formatting providers independently ofLanguageServiceandLanguageClient. It honors R editor overrides and provider trigger characters, preserves cursor and undo behavior, suppresses on-type formatting during paste, and discards pending replies after input changes, session replacement, or manager disposal.Provider and other extension tests run with the built-in language server disabled, with an activation-only setup before tests mock VS Code APIs. The real Interactive integration suite activates the extension and waits for its language server itself. CI's existing log patterns cover the separate profiles. The existing arf interrupt test uses short sleeps and keeps readiness and blocking evaluation in one expression to avoid reproduced interrupt races on macOS and Linux. The multi-process restart test has a scoped two-minute budget for cold setup and repeated preflight/restart operations, while retaining individual wait limits. On-type formatting tests wait for both the document and the separately delivered cursor update, avoiding a Linux selection assertion race.
Validation on macOS with VS Code 1.141.0:
r.lsp.enabled=false, including seven independent-provider tests covering custom triggers, settings, paste ranges and forwarding, cursor/undo behavior, delayed replies, and single-character paste with format-on-paste enabled or disabled. The new paste regression failed before the fix and passed afterward; typing still formats after paste.