Skip to content

Enable automatic formatting in Interactive input - #1867

Merged
renkun-ken merged 13 commits into
mainfrom
codex/interactive-input-language-features
Oct 11, 2026
Merged

renkun-ken merged 13 commits into
mainfrom
codex/interactive-input-language-features

Conversation

@renkun-ken

@renkun-ken renkun-ken commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

R Interactive's native input editor omits automatic formatting. Add a single bridge so typing (1+1) formats it to (1 + 1) with editor.formatOnType, and pasted ranges respect editor.formatOnPaste.

InteractiveManager owns the bridge, which requests edits from VS Code's registered formatting providers independently of LanguageService and LanguageClient. 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:

  • 496 provider/extension tests passed with 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.
  • All 59 real R integration tests passed after removing duplicate global activation setup, scoping the restart-test timeout, and synchronizing cursor assertions. All seven independent-provider formatting tests were also rerun after the cursor synchronization change.
  • Extension build, TypeScript type checking, lint, and whitespace checks passed.
  • All 196 Node tests passed (the renv case was rerun after installing the missing local dependency).
  • The arf adoption test passed 20 consecutive runs after keeping its readiness marker and sleep loop in one expression. Widening the inter-expression hook reproduced the CI timeout before the fix and passed afterward.

@renkun-ken renkun-ken changed the title Enable formatting and occurrence highlighting in Interactive input Enable automatic formatting in Interactive input Oct 11, 2026
@renkun-ken
renkun-ken requested a review from eitsupi October 11, 2026 14:51

@eitsupi eitsupi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@renkun-ken

Copy link
Copy Markdown
Member Author

Addressed in eeba0aa.

InteractiveManager now owns InteractiveInputFeatures, and the bridge no longer depends on LanguageService or LanguageClient. On-type and paste formatting use VS Code's registered providers, including independent formatters with r.lsp.enabled=false. VS Code checks the selected provider's trigger characters, and pending edits are discarded if the input changes, the session is replaced, or the manager is disposed.

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.

@renkun-ken
renkun-ken requested a review from eitsupi October 11, 2026 16:08

@eitsupi eitsupi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@renkun-ken
renkun-ken requested a review from eitsupi October 11, 2026 16:50
@renkun-ken
renkun-ken merged commit b013dda into main Oct 11, 2026
5 checks passed
@renkun-ken
renkun-ken deleted the codex/interactive-input-language-features branch October 11, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants