Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function activate(context: vscode.ExtensionContext) {
const endLine = e.document.lineCount - lineNumber > 20 ? lineNumber + 20 : e.document.lineCount;
const multiLineText = e.document.getText(new vscode.Range(startLine, 0, endLine, 200));
let matches = multiLineText.match(regex);
if (lineText.includes(';') || lineText.includes(",") || lineText.substring(0, currentChar).includes(":")) {
if (lineText.includes(",") || lineText.substring(0, currentChar).includes(":")) {
// treat as a single line
matches = null;
}
Expand Down
18 changes: 18 additions & 0 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ suite('Extension Test Suite', () => {
assert.strictEqual(doc.getText(), '"\\${"');
});
});

let htmlTag = '"<div className="hello $"/>"';
test('add bracket to htmlTag', () => {
return withRandomFileEditor(htmlTag, 'ts', async (editor, doc) => {
await editor.insertSnippet(new vscode.SnippetString("{"), new vscode.Position(0, 24));
await delay(500);
assert.strictEqual(doc.getText(), '"<div className={`hello ${}`}/>"');
});
});

let htmlTagWithSemicolon = '"<div className="hello $"/>;"';
test('add bracket to htmlTag with ;', () => {
return withRandomFileEditor(htmlTagWithSemicolon, 'ts', async (editor, doc) => {
await editor.insertSnippet(new vscode.SnippetString("{"), new vscode.Position(0, 24));
await delay(500);
assert.strictEqual(doc.getText(), '"<div className={`hello ${}`}/>;"');
});
});
});
export function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
Expand Down