admin管理员组文章数量:1026373
UPD: Never mind I am just bad at reading sources!
I am using Colonize extension. The extension adding ; at the end of the line by hitting Shift + Enter. However when I get suggestions they get selected. I don't want this.
First thing I thought of is to check the repo issues : one person also thinks the same. Then I decided to check source code and I don't see anything that actually selects the suggestion.
I've tried to add to keybindings.json all commands to be disabled, and it works without colonize!
{
"key": "shift+Enter",
"command": "-acceptSelectedSuggestion",
"when": "true"
},
{
"key": "shift+Enter",
"command": "-acceptSelectedSuggestionOnEnter",
"when": "true"
},
{
"key": "shift+enter",
"command": "-acceptAlternativeSelectedSuggestion",
"when": "true"
}
The logical next step would be to check the source code of the extension. Fortunately it is very short and it just uses editBuilder to insert semicolon. I suspect that this statement could be the issue, but after commenting this portion in js file of the extension nothing changed it terms of accepting the suggestion :
vscodemands.executeCommand("acceptSelectedSuggestion").then(() => {
var lineIndex = editor.selection.active.line;
var lineObject = editor.document.lineAt(lineIndex);
var lineLength = lineObject.text.length;
if (
lineObject.text.charAt(lineLength - 1) !== ";" &&
!lineObject.isEmptyOrWhitespace
) {
var insertionSuccess = editor.edit((editBuilder) => {
editBuilder.insert(new vscode.Position(lineIndex, lineLength), ";lol"); // MOD HERE!
});
if (!insertionSuccess) return;
}
if (option === "hold") return;
// MOD HERE !
// option === 'endline'
// ? vscodemands.executeCommand('cursorEnd')
// : vscodemands.executeCommand('editor.action.insertLineAfter')
});
Here is a demo gif (lol shows that I made modification):
Steps to Reproduce:
- Download the extension
- Start typing to see suggestioins
- Press shift + Enter
- Watch semicolon added and first suggestion get accepted
Version: 1.95.3 (user setup)
Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813
Date: 2024-11-13T14:50:04.152Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.22631
UPD: Never mind I am just bad at reading sources!
I am using Colonize extension. The extension adding ; at the end of the line by hitting Shift + Enter. However when I get suggestions they get selected. I don't want this.
First thing I thought of is to check the repo issues : one person also thinks the same. Then I decided to check source code and I don't see anything that actually selects the suggestion.
I've tried to add to keybindings.json all commands to be disabled, and it works without colonize!
{
"key": "shift+Enter",
"command": "-acceptSelectedSuggestion",
"when": "true"
},
{
"key": "shift+Enter",
"command": "-acceptSelectedSuggestionOnEnter",
"when": "true"
},
{
"key": "shift+enter",
"command": "-acceptAlternativeSelectedSuggestion",
"when": "true"
}
The logical next step would be to check the source code of the extension. Fortunately it is very short and it just uses editBuilder to insert semicolon. I suspect that this statement could be the issue, but after commenting this portion in js file of the extension nothing changed it terms of accepting the suggestion :
vscodemands.executeCommand("acceptSelectedSuggestion").then(() => {
var lineIndex = editor.selection.active.line;
var lineObject = editor.document.lineAt(lineIndex);
var lineLength = lineObject.text.length;
if (
lineObject.text.charAt(lineLength - 1) !== ";" &&
!lineObject.isEmptyOrWhitespace
) {
var insertionSuccess = editor.edit((editBuilder) => {
editBuilder.insert(new vscode.Position(lineIndex, lineLength), ";lol"); // MOD HERE!
});
if (!insertionSuccess) return;
}
if (option === "hold") return;
// MOD HERE !
// option === 'endline'
// ? vscodemands.executeCommand('cursorEnd')
// : vscodemands.executeCommand('editor.action.insertLineAfter')
});
Here is a demo gif (lol shows that I made modification):
Steps to Reproduce:
- Download the extension
- Start typing to see suggestioins
- Press shift + Enter
- Watch semicolon added and first suggestion get accepted
Version: 1.95.3 (user setup)
Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813
Date: 2024-11-13T14:50:04.152Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.22631
Share
Improve this question
edited Nov 17, 2024 at 11:27
Askhento
asked Nov 16, 2024 at 23:41
AskhentoAskhento
6596 silver badges18 bronze badges
1 Answer
Reset to default 1First make sure you don't have any extensions that affect the suggestions. Try overriding the behavior of these keys directly, write in keybindings.json
{
"key": "shift+enter",
"command": "colonize.insertSemicolonAtEndOfLine",
"when": "editorTextFocus"
}
You can try disabling autocompletion by writing in settings.json
"editor.acceptSuggestionOnEnter": "off"
If it's not too imperative that shift+enter is used, you can just change the binding :)
UPD: Never mind I am just bad at reading sources!
I am using Colonize extension. The extension adding ; at the end of the line by hitting Shift + Enter. However when I get suggestions they get selected. I don't want this.
First thing I thought of is to check the repo issues : one person also thinks the same. Then I decided to check source code and I don't see anything that actually selects the suggestion.
I've tried to add to keybindings.json all commands to be disabled, and it works without colonize!
{
"key": "shift+Enter",
"command": "-acceptSelectedSuggestion",
"when": "true"
},
{
"key": "shift+Enter",
"command": "-acceptSelectedSuggestionOnEnter",
"when": "true"
},
{
"key": "shift+enter",
"command": "-acceptAlternativeSelectedSuggestion",
"when": "true"
}
The logical next step would be to check the source code of the extension. Fortunately it is very short and it just uses editBuilder to insert semicolon. I suspect that this statement could be the issue, but after commenting this portion in js file of the extension nothing changed it terms of accepting the suggestion :
vscodemands.executeCommand("acceptSelectedSuggestion").then(() => {
var lineIndex = editor.selection.active.line;
var lineObject = editor.document.lineAt(lineIndex);
var lineLength = lineObject.text.length;
if (
lineObject.text.charAt(lineLength - 1) !== ";" &&
!lineObject.isEmptyOrWhitespace
) {
var insertionSuccess = editor.edit((editBuilder) => {
editBuilder.insert(new vscode.Position(lineIndex, lineLength), ";lol"); // MOD HERE!
});
if (!insertionSuccess) return;
}
if (option === "hold") return;
// MOD HERE !
// option === 'endline'
// ? vscodemands.executeCommand('cursorEnd')
// : vscodemands.executeCommand('editor.action.insertLineAfter')
});
Here is a demo gif (lol shows that I made modification):
Steps to Reproduce:
- Download the extension
- Start typing to see suggestioins
- Press shift + Enter
- Watch semicolon added and first suggestion get accepted
Version: 1.95.3 (user setup)
Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813
Date: 2024-11-13T14:50:04.152Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.22631
UPD: Never mind I am just bad at reading sources!
I am using Colonize extension. The extension adding ; at the end of the line by hitting Shift + Enter. However when I get suggestions they get selected. I don't want this.
First thing I thought of is to check the repo issues : one person also thinks the same. Then I decided to check source code and I don't see anything that actually selects the suggestion.
I've tried to add to keybindings.json all commands to be disabled, and it works without colonize!
{
"key": "shift+Enter",
"command": "-acceptSelectedSuggestion",
"when": "true"
},
{
"key": "shift+Enter",
"command": "-acceptSelectedSuggestionOnEnter",
"when": "true"
},
{
"key": "shift+enter",
"command": "-acceptAlternativeSelectedSuggestion",
"when": "true"
}
The logical next step would be to check the source code of the extension. Fortunately it is very short and it just uses editBuilder to insert semicolon. I suspect that this statement could be the issue, but after commenting this portion in js file of the extension nothing changed it terms of accepting the suggestion :
vscodemands.executeCommand("acceptSelectedSuggestion").then(() => {
var lineIndex = editor.selection.active.line;
var lineObject = editor.document.lineAt(lineIndex);
var lineLength = lineObject.text.length;
if (
lineObject.text.charAt(lineLength - 1) !== ";" &&
!lineObject.isEmptyOrWhitespace
) {
var insertionSuccess = editor.edit((editBuilder) => {
editBuilder.insert(new vscode.Position(lineIndex, lineLength), ";lol"); // MOD HERE!
});
if (!insertionSuccess) return;
}
if (option === "hold") return;
// MOD HERE !
// option === 'endline'
// ? vscodemands.executeCommand('cursorEnd')
// : vscodemands.executeCommand('editor.action.insertLineAfter')
});
Here is a demo gif (lol shows that I made modification):
Steps to Reproduce:
- Download the extension
- Start typing to see suggestioins
- Press shift + Enter
- Watch semicolon added and first suggestion get accepted
Version: 1.95.3 (user setup)
Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813
Date: 2024-11-13T14:50:04.152Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.22631
Share
Improve this question
edited Nov 17, 2024 at 11:27
Askhento
asked Nov 16, 2024 at 23:41
AskhentoAskhento
6596 silver badges18 bronze badges
1 Answer
Reset to default 1First make sure you don't have any extensions that affect the suggestions. Try overriding the behavior of these keys directly, write in keybindings.json
{
"key": "shift+enter",
"command": "colonize.insertSemicolonAtEndOfLine",
"when": "editorTextFocus"
}
You can try disabling autocompletion by writing in settings.json
"editor.acceptSuggestionOnEnter": "off"
If it's not too imperative that shift+enter is used, you can just change the binding :)
本文标签: visual studio codeVSCode editBuilder implicitly accepts suggestionsStack Overflow
版权声明:本文标题:visual studio code - VSCode editBuilder implicitly accepts suggestions - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745643489a2160885.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论