New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not auto-close when ending with open #55315

Merged
merged 3 commits into from Sep 5, 2018
Jump to file or symbol
Failed to load files and symbols.
+36 −5
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

auto close eletric characters when necessary.

  • Loading branch information...
rebornix committed Sep 5, 2018
commit 2e9eada30666025cc9a51868c9466990302abff9
@@ -121,8 +121,8 @@ export class BracketElectricCharacterSupport {
}
// check if the full open bracket matches
let start = column - pair.open.length;
let actual = line.substring(start, start + pair.open.length) + character;
let start = column - pair.open.length + 1;
let actual = line.substring(start - 1, column - 1) + character;
if (actual !== pair.open) {
continue;
}
@@ -3940,7 +3940,6 @@ suite('autoClosingPairs', () => {
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: 'b"', close: '"' },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
{ open: '\"', close: '\"', notIn: ['string'] },
{ open: '`', close: '`', notIn: ['string', 'comment'] },
@@ -4386,14 +4385,46 @@ suite('autoClosingPairs', () => {
});
test('issue #55314: Do not auto-close when ending with open', () => {
let mode = new AutoClosingMode();
const languageId = new LanguageIdentifier('myElectricMode', 5);
class ElectricMode extends MockMode {
constructor() {
super(languageId);
this._register(LanguageConfigurationRegistry.register(this.getLanguageIdentifier(), {
autoClosingPairs: [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
{ open: '\"', close: '\"', notIn: ['string'] },
{ open: 'B\"', close: '\"', notIn: ['string', 'comment'] },
{ open: '`', close: '`', notIn: ['string', 'comment'] },
{ open: '/**', close: ' */', notIn: ['string'] }
],
}));
}
}
const mode = new ElectricMode();
usingCursor({
text: [
'little lamb',
'little goat',
'little LAMB',
'little sheep',
'Big LAMB'
],
languageIdentifier: mode.getLanguageIdentifier()
}, (model, cursor) => {
model.forceTokenization(model.getLineCount());
assertType(model, cursor, 1, 4, '"', '"', `does not double quote when ending with open`);
model.forceTokenization(model.getLineCount());
assertType(model, cursor, 2, 4, '"', '"', `does not double quote when ending with open`);
model.forceTokenization(model.getLineCount());
assertType(model, cursor, 3, 4, '"', '"', `does not double quote when ending with open`);
model.forceTokenization(model.getLineCount());
assertType(model, cursor, 4, 2, '"', '""', `double quote when ending with open`);
model.forceTokenization(model.getLineCount());
assertType(model, cursor, 4, 3, '"', '"', `does not double quote when ending with open`);
});
mode.dispose();
});
ProTip! Use n and p to navigate between commits in a pull request.