Repository navigation
4.3.25: dev > main - #586
Merged
Merged
Conversation
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 (#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.
VS Code hands the completion provider each notebook cell as a document of its own, so the window of code round the cursor stopped at the cell's edges. In a Jupyter notebook that is usually most of what matters: the imports, the data frame and the helpers a cell uses were defined in the cells above, and the model, shown only the cell, guessed at them or wrote code in another language altogether (#430). When the document is a notebook cell, the code cells of the open notebook in that cell's language are now joined in order, a blank line between each, and the prefix and suffix window is cut from that text with the cursor moved to its place in it. Markdown cells and code cells in another language (a SQL cell in a Python notebook) are left out, as they would not read as part of the same code. The usual limits still apply: twinny.contextLength lines, the character caps, and the step-aligned start that lets the server reuse its prompt cache. getPrefixSuffix now takes only the lineCount and getText it reads, so the joined text is passed to it through a small view with the same clamping as a document. The prefetch check uses the same window, so a prefetched completion in a notebook is recognised as on the way. Tests: the view matches a real document for every window and clamped range tried; cells are joined and the cell's first line found, with markdown and other-language cells skipped; and a completion asked in the middle cell of a real jupyter-notebook document is made with the cell above as prefix and the one below as suffix.
…line suggestion
The editor reuses what it has for the same place without asking the provider, so asking for the other length did nothing. Claude-Session: https://claude.ai/code/session_01CKXDgYQNBL8Zw8LwpfL1jd
The open conversation was kept in global state, which every VS Code window shares. With two windows open, a reply saved in one went into whichever conversation the other window had opened last. The open conversation now lives in workspace state; the conversation list stays global.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completions in a notebook read the cells round them (#580), and two new commands ask for a one-line or several-line suggestion (#579).
Closes #430. Closes #201.
#579 also gets a fix on top: its commands did nothing while a suggestion was already showing, because the editor reused it without asking the provider. A regression test covers it.
P2P gateway server: cancels the remote request when the caller hangs upis flaky and also fails on cleandev. Merging this publishes 4.3.25 to the Marketplace and Open VSX.