Skip to content

Commands to ask for a one-line or a several-line suggestion - #579

Merged
m1ab0t merged 1 commit into
twinnydotdev:devfrom
officialasishkumar:feat/line-and-block-suggestion-commands
Nov 21, 2026
Merged

m1ab0t merged 1 commit into
twinnydotdev:devfrom
officialasishkumar:feat/line-and-block-suggestion-commands

Conversation

@officialasishkumar

Copy link
Copy Markdown
Contributor

Closes #201

Whether an inline suggestion is one line or several is decided by twinny.multilineCompletionsEnabled and a guess from the code round the cursor. If you usually want one line and a block only now and then (or the other way round), there was no way to ask for the other length when you wanted it.

  • Two new commands trigger a suggestion at the cursor with the length you choose, whatever the setting and the guess would pick:
    • Twinny - Suggest one line (twinny.suggestLine)
    • Twinny - Suggest several lines (twinny.suggestLines), up to twinny.maxLines
  • They have no default keys, as suggested in the issue, so nothing clashes with Alt+\ or other extensions. You can bind them in Keyboard Shortcuts, and they show in the command palette while an editable editor has focus. The descriptions of multilineCompletionsEnabled and maxLines mention them.
  • How it works: the command saves the length along with the document, version and cursor position, then runs editor.action.inlineSuggest.trigger. The first invoked request uses that length, and only if it was made at that same place. The saved length is cleared either way, so the next suggestion follows the settings again.
  • A request made by the command never reuses the suggestion already on screen or the one prefetched for the next line, because either could be the other length. It is also cached under its own key. Typing through a suggestion the command showed still shows the rest of it, as before.
  • Tests (completion-lifecycle.test.ts) run the command through the editor, with the provider registered against a fake Ollama. They cover several lines where the settings give one, one line where the settings give a block, and the saved length being cleared once a request somewhere else uses it. The first two fail without the change. To share the fake Ollama with the new suite, the prefetch suite's helpers move up one level. They are otherwise unchanged apart from a content parameter.

Checked: tsc, eslint src and the build are clean. The new tests and the commands test pass. In the full npm test run, 876 tests passed, and 5 Chat edit_file / Agent reply tests failed in my headless Linux container. Those 5 fail the same way on main without this change. npm run test:sqlite passes.

Whether an inline suggestion runs over several lines is decided by
twinny.multilineCompletionsEnabled and a guess from the code round the
cursor. Users who usually want one line, and a block only now and then
(or the other way round), had no way to ask for the other length at the
moment they wanted it (twinnydotdev#201).

Two commands now trigger a suggestion at the cursor with the length
chosen by the user, whatever the setting and the guess would pick:

- "Twinny - Suggest one line" (twinny.suggestLine)
- "Twinny - Suggest several lines" (twinny.suggestLines), up to
  twinny.maxLines

They have no default keys, so nothing clashes with Alt+\ or other
extensions; they can be bound in Keyboard Shortcuts and show in the
command palette while an editable editor has focus.

The command records the length with the document, version and cursor
it was asked at, then runs editor.action.inlineSuggest.trigger. The
first invoked request takes it, and uses it only if it is for that same
place, so the next suggestion follows the settings again. A request
with an asked length is never served from the suggestion on screen or
the one prefetched for the next line, since either may be the other
length, and it is cached under its own key. Typing through a suggestion
the command showed still serves the rest of it. The settings'
descriptions mention the commands.

Tests drive the command through the editor with the provider registered
against a fake Ollama: several lines where the settings give one, one
line where they give a block, and the asked length being let go once a
request elsewhere takes it. The prefetch tests' helpers move up a level
so the new suite can share them.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-19T22:05:43.785385Z
We couldn’t complete this review. Comment @codex review to try again.
7ddcdb5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@m1ab0t
m1ab0t changed the base branch from main to dev November 21, 2026 21:17
@m1ab0t
m1ab0t merged commit cf1d42f into twinnydotdev:dev Nov 21, 2026
1 check failed
@m1ab0t m1ab0t mentioned this pull request Nov 21, 2026
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.

Different shortcuts for single-line or multi-line suggestions

2 participants