From 7eebacb7e843b42d37bd87e25c1e660f78ef7c7c Mon Sep 17 00:00:00 2001 From: Fred Wu Date: Sat, 11 Jul 2026 15:35:28 +1000 Subject: [PATCH 1/2] Change empty completion trigger to F7 --- CHANGELOG.md | 4 ++-- README.md | 2 +- docs/IMPLEMENTATION.md | 14 +++++++++----- docs/MANUALTEST.Rmd | 12 ++++++++++-- package.json | 5 ++--- src/Terminal/keyProcessor.ts | 8 ++++++++ src/Terminal/rTerminal.ts | 3 +++ 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee9d0eb..e255eac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to R Console will be documented in this file. ### Added -- Added `Alt+Esc` (`⌥ Esc` on macOS) to open console completions anywhere, including positions without a completion prefix or context. +- Added `F7` to open console completions anywhere, including positions without a completion prefix or context. - Added `Restore Default Name` to the console tab menu for returning a renamed console to `R Console (PID)`. ### Changed @@ -14,7 +14,7 @@ All notable changes to R Console will be documented in this file. - Console syntax highlighting now follows the active VS Code theme without depending on the language server. - Completion suggestions now keep runtime and language-server results in their existing groups. - Runtime completions now appear immediately while language-server suggestions continue loading. -- Completions opened without a prefix now update as you type, including inside empty `[]` / `()` contexts and when using `Alt+Esc`. +- Completions opened without a prefix now update as you type, including inside empty `[]` / `()` contexts and when using the completion shortcut. - Runtime and language-server completions are now both available in normal expression positions, including function calls and data-frame/table expressions; `pkg::`, `pkg:::`, `$`, `@`, quoted column-name, and `[[` completions remain limited to their matching context. - Further reduced the delay when opening language-server suggestions. - Renamed consoles and their session-manager labels now keep their names when the console is reopened or detached and reattached. diff --git a/README.md b/README.md index 65232c5..5fec163 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ R Console is a lightweight R console for VS Code that runs R inside a custom pse - Custom R console hosted in the VS Code terminal area. - Persistent R console sessions that can be attached, detached, or closed from VS Code, while preserving custom console names. -- Tab-triggered completion, including objects from the active R session and runtime `$` / `@` member completion. `Alt+Esc` (`⌥ Esc` on macOS) opens the completion window at the cursor, including empty positions where Tab is used for indentation. +- Tab-triggered completion, including objects from the active R session and runtime `$` / `@` member completion. `F7` opens the completion window at the cursor, including empty positions where Tab is used for indentation. - Syntax highlighting that follows the active VS Code color theme. - Multiline editing with local history navigation, reverse search, and long-input rendering. - Auto-matching brackets and quotes. diff --git a/docs/IMPLEMENTATION.md b/docs/IMPLEMENTATION.md index 3fc4b2f..98dab8e 100644 --- a/docs/IMPLEMENTATION.md +++ b/docs/IMPLEMENTATION.md @@ -570,11 +570,15 @@ inherits the normalized R environment used by the console runtime. Diagnostics are disabled because the virtual console document exists only to provide completion context and must not be linted as a source file. -The contributed `Alt+Esc` keybinding is limited to an active R Console and -invokes its internal forced-completion handler, preventing VS Code's terminal -suggestion command from consuming the shortcut first. Forced completion shows -the Quick Pick before full workspace and language-server results arrive, then -fills the open window asynchronously. +The contributed `F7` keybinding is limited to an active R Console and invokes +its internal forced-completion handler when VS Code handles the keybinding. If +VS Code instead forwards F7 to the pseudoterminal, `KeyProcessor` maps the +standard xterm `ESC [ 18 ~` sequence to the same forced-completion handler. +This fallback keeps completion available when +`terminal.integrated.sendKeybindingsToShell` is enabled without changing the +separate Tab action used for indentation and contextual completion. Forced +completion shows the Quick Pick before full workspace and language-server +results arrive, then fills the open window asynchronously. Console syntax highlighting is separate from language-server completion. It is implemented locally by `src/Terminal/consoleSyntax.ts` and diff --git a/docs/MANUALTEST.Rmd b/docs/MANUALTEST.Rmd index 08cae56..9946fbe 100644 --- a/docs/MANUALTEST.Rmd +++ b/docs/MANUALTEST.Rmd @@ -446,14 +446,22 @@ lm_test <- lm(mpg ~ wt + cyl, data = mtcars) Now test in the console: -- press `Alt+Esc` at an empty prompt and after typing a partial name +- press `F7` at an empty prompt and after typing a partial name (use `Fn+F7` + on macOS when the top row controls media features) +- press Tab at an empty prompt, then after typing a partial name - type `df_test$` and request completion - type `df_test[` and request completion inside brackets - type `stats::f` and request package completion +- temporarily set `terminal.integrated.sendKeybindingsToShell` to `true`, + reload the VS Code window, and repeat the F7 checks; restore the setting + afterward Expected: -- `Alt+Esc` opens the R Console completion window +- F7 opens the R Console completion window with either terminal keybinding + dispatch mode +- Tab at an empty prompt inserts indentation, while Tab after a partial name + requests contextual completion - `$` completions include `alpha`, `beta`, `gamma` - `[` completions on `df_test` include `alpha`, `beta`, `gamma` - completion still works after several commands, not just right after startup diff --git a/package.json b/package.json index cdaa952..ffbc0a3 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "keybindings": [ { "command": "r-console.triggerCompletion", - "key": "alt+escape", + "key": "f7", "when": "terminalFocus && rConsole.consoleActive" }, { @@ -132,8 +132,7 @@ ], "configurationDefaults": { "terminal.integrated.commandsToSkipShell": [ - "r-console.insertPipeOperator", - "r-console.triggerCompletion" + "r-console.insertPipeOperator" ] }, "configuration": { diff --git a/src/Terminal/keyProcessor.ts b/src/Terminal/keyProcessor.ts index 92301a4..983f395 100644 --- a/src/Terminal/keyProcessor.ts +++ b/src/Terminal/keyProcessor.ts @@ -9,6 +9,7 @@ export type KeyAction = | { type: "word-right" } | { type: "tab" } | { type: "backtab" } + | { type: "completion" } | { type: "escape" } | { type: "ctrl_c" } | { type: "ctrl_d" } @@ -29,6 +30,10 @@ const CSI_6: Map = new Map([ ["\x1b[1;5D", { type: "word-left" }], ]); +const CSI_5: Map = new Map([ + ["\x1b[18~", { type: "completion" }], +]); + const CSI_4: Map = new Map([ ["\x1b[3~", { type: "delete" }], ["\x1b[1~", { type: "home" }], @@ -100,6 +105,9 @@ function getCsiAction(sequence: string): KeyAction | undefined { if (sequence.length === 6) { return CSI_6.get(sequence); } + if (sequence.length === 5) { + return CSI_5.get(sequence); + } if (sequence.length === 4) { return CSI_4.get(sequence); } diff --git a/src/Terminal/rTerminal.ts b/src/Terminal/rTerminal.ts index 54c64a6..ab4ef85 100644 --- a/src/Terminal/rTerminal.ts +++ b/src/Terminal/rTerminal.ts @@ -1198,6 +1198,9 @@ export class RTerminal implements vscode.Pseudoterminal { } return; } + case "completion": + this.triggerCompletion(); + return; case "backtab": { this.expandForEdit(); const beforeCursor = this.inputState.currentLineBeforeCursor; From f675200156bfe2ab6ebc7b9066ab57a747f174e7 Mon Sep 17 00:00:00 2001 From: Fred Wu Date: Sat, 11 Jul 2026 15:49:05 +1000 Subject: [PATCH 2/2] Bump version to 0.4.1 --- CHANGELOG.md | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e255eac..bd52b3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to R Console will be documented in this file. -## [0.4.0] - 2026-07-11 +## [0.4.1] - 2026-07-11 ### Added @@ -12,13 +12,13 @@ All notable changes to R Console will be documented in this file. ### Changed - Console syntax highlighting now follows the active VS Code theme without depending on the language server. +- Persistent-session reattachment now warns when the configured R path differs from the running session, with options to close the session or open the R path setting. - Completion suggestions now keep runtime and language-server results in their existing groups. - Runtime completions now appear immediately while language-server suggestions continue loading. - Completions opened without a prefix now update as you type, including inside empty `[]` / `()` contexts and when using the completion shortcut. - Runtime and language-server completions are now both available in normal expression positions, including function calls and data-frame/table expressions; `pkg::`, `pkg:::`, `$`, `@`, quoted column-name, and `[[` completions remain limited to their matching context. - Further reduced the delay when opening language-server suggestions. - Renamed consoles and their session-manager labels now keep their names when the console is reopened or detached and reattached. -- Persistent-session reattachment now warns when the configured R path differs from the running session, with options to close the session or open the R path setting. ### Fixed diff --git a/package-lock.json b/package-lock.json index 4791b12..954180a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vsc-r-console", - "version": "0.4.0", + "version": "0.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vsc-r-console", - "version": "0.4.0", + "version": "0.4.1", "license": "SEE LICENSE IN LICENSE", "dependencies": { "@xterm/headless": "^6.0.0", diff --git a/package.json b/package.json index ffbc0a3..986ef91 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vsc-r-console", "displayName": "R Console for VS Code", "description": "A lightweight R console for VS Code", - "version": "0.4.0", + "version": "0.4.1", "publisher": "RConsole", "license": "SEE LICENSE IN LICENSE", "icon": "images/Rlogo.png",