Skip to content

Commit

Permalink
Merge pull request #135197 from thebinarysearchtree/Tagged-templates
Browse files Browse the repository at this point in the history
Remove backticks from word character fix
  • Loading branch information
alexdima committed Oct 27, 2021
2 parents a993ada + 5382a52 commit 8eae60d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vs/editor/common/controller/cursorTypeOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ export class TypeOperations {
}

// Do not auto-close ' or " after a word character
if (autoClosingPair.open.length === 1 && chIsQuote && autoCloseConfig !== 'always') {
if (autoClosingPair.open.length === 1 && (ch === '\'' || ch === '"') && autoCloseConfig !== 'always') {
const wordSeparators = getMapForWordSeparators(config.wordSeparators);
if (insertOpenCharacter && position.column > 1 && wordSeparators.get(lineText.charCodeAt(position.column - 2)) === WordCharacterClass.Regular) {
return null;
Expand Down
12 changes: 12 additions & 0 deletions src/vs/editor/test/browser/controller/cursor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4878,6 +4878,18 @@ suite('autoClosingPairs', () => {
model.undo();
}

test('issue #61070: backtick (`) should auto-close after a word character', () => {
let mode = new AutoClosingMode();
usingCursor({
text: ['const markup = highlight'],
languageId: mode.languageId
}, (editor, model, viewModel) => {
model.forceTokenization(1);
assertType(editor, model, viewModel, 1, 25, '`', '``', `auto closes \` @ (1, 25)`);
});
mode.dispose();
});

test('open parens: default', () => {
let mode = new AutoClosingMode();
usingCursor({
Expand Down

0 comments on commit 8eae60d

Please sign in to comment.