Skip to content

Commit

Permalink
make single line the default again
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Mar 22, 2024
1 parent 93346d6 commit 0459106
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
"twinny.useMultiLineCompletions": {
"order": 14,
"type": "boolean",
"default": true,
"default": false,
"description": "Use multiline completions"
},
"twinny.useFileContext": {
Expand Down Expand Up @@ -359,7 +359,7 @@
"twinny.enableSubsequentCompletions": {
"order": 19,
"type": "boolean",
"default": false,
"default": true,
"description": "Enable this setting to allow twinny to keep making subsequent completion requests to the API after the last completion request was accepted."
},
"twinny.keepAlive": {
Expand Down
3 changes: 3 additions & 0 deletions src/extension/providers/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class CompletionProvider implements InlineCompletionItemProvider {
private _fimTemplateFormat = this._config.get('fimTemplateFormat') as string
private _keepAlive = this._config.get('keepAlive') as string | number
private _lastCompletionText = ''
private _lastCompletionMultiline = false
private _lock: AsyncLock
private _logger: Logger
private _nonce = 0
Expand Down Expand Up @@ -193,6 +194,7 @@ export class CompletionProvider implements InlineCompletionItemProvider {
}

public getLastCompletion = () => this._lastCompletionText
public getLastCompletionMultiLine = () => this._lastCompletionMultiline

public setAcceptedLastCompletion(value: boolean) {
this._acceptedLastCompletion = value
Expand Down Expand Up @@ -446,6 +448,7 @@ export class CompletionProvider implements InlineCompletionItemProvider {

this._statusBar.text = '🤖'
this._lastCompletionText = insertText
this._lastCompletionMultiline = this._isMultiLineCompletion

return [
new InlineCompletionItem(
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,14 @@ export async function activate(context: ExtensionContext) {
const changes = e.contentChanges[0]
if (!changes) return
const lastCompletion = completionProvider.getLastCompletion()
const isLastCompltionMultiline =
completionProvider.getLastCompletionMultiLine()

if (
changes.text &&
lastCompletion &&
changes.text === lastCompletion
changes.text === lastCompletion &&
isLastCompltionMultiline
) {
completionProvider.setAcceptedLastCompletion(true)
}
Expand Down

0 comments on commit 0459106

Please sign in to comment.