Skip to content

Commit fdb9100

Browse files
committed
adding default bullet point won't override bracket autocomplete
1 parent 727e52e commit fdb9100

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/commands/commandManager.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { PasteWithBullets } from './pasteWithBullets';
66
import { EnterKeyHandler } from './enterKey';
77
import { getBulletFromLine } from '../utils/bulletPointUtils.vscode';
88
import { getBulletStyleFromAdjacentLines } from '../utils/bulletStyleUtils';
9-
// ...existing code...
109
import { Configuration } from '../config/configuration';
1110
import { QueryService } from '../queries/queryService';
1211

@@ -81,6 +80,24 @@ export class CommandManager {
8180
await vscode.commands.executeCommand('default:type', args);
8281
return;
8382
}
83+
84+
// --- Auto-completion Handling ---
85+
// Defer to default handler for chars that trigger auto-completion to prevent interference.
86+
const autoCompleteChars = ['[', '{', '(', "'", '"'];
87+
if (autoCompleteChars.includes(typedChar) && line.text.trim().length === 0) {
88+
await vscode.commands.executeCommand('default:type', args);
89+
// Now, check if we should add a bullet *before* the auto-completed pair.
90+
const lineAfterType = editor.document.lineAt(editor.selection.active.line);
91+
if (lineAfterType.text.trim().length > 0) { // Check if something was actually inserted
92+
const indent = line.firstNonWhitespaceCharacterIndex;
93+
const bulletToInsert = getBulletStyleFromAdjacentLines(editor.document, position.line, indent, '• ');
94+
await editor.edit(editBuilder => {
95+
editBuilder.insert(new vscode.Position(position.line, indent), bulletToInsert);
96+
});
97+
}
98+
return; // Stop further processing
99+
}
100+
84101
if (typedChar === '[' && position.character > 0 && line.text.charAt(position.character - 1) === '[') {
85102
await vscode.commands.executeCommand('default:type', args);
86103
return;

0 commit comments

Comments
 (0)