mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Fix #66284.
This commit is contained in:
parent
cf41b420d8
commit
c4c427198d
|
@ -223,7 +223,7 @@ export function activate(context: ExtensionContext) {
|
|||
let languageConfiguration: LanguageConfiguration = {
|
||||
wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|[^\s{}\[\],:]+/,
|
||||
indentationRules: {
|
||||
increaseIndentPattern: /^.*(\{[^}]*|\[[^\]]*)$/,
|
||||
increaseIndentPattern: /({+(?=([^"]*"[^"]*")*[^"}]*$))|(\[+(?=([^"]*"[^"]*")*[^"\]]*$))/,
|
||||
decreaseIndentPattern: /^\s*[}\]],?\s*$/
|
||||
}
|
||||
};
|
||||
|
|
|
@ -223,4 +223,4 @@ export class ButtonGroup extends Disposable {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3633,6 +3633,75 @@ suite('Editor Controller - Indentation Rules', () => {
|
|||
model.dispose();
|
||||
mode.dispose();
|
||||
});
|
||||
|
||||
test('', () => {
|
||||
class JSONMode extends MockMode {
|
||||
private static readonly _id = new LanguageIdentifier('indentRulesMode', 4);
|
||||
constructor() {
|
||||
super(JSONMode._id);
|
||||
this._register(LanguageConfigurationRegistry.register(this.getLanguageIdentifier(), {
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
indentationRules: {
|
||||
increaseIndentPattern: new RegExp('^.*\\{[^}\"\\\']*$|^.*\\([^\\)\"\\\']*$|^\\s*(public|private|protected):\\s*$|^\\s*@(public|private|protected)\\s*$|^\\s*\\{\\}$'),
|
||||
decreaseIndentPattern: new RegExp('^\\s*(\\s*/[*].*[*]/\\s*)*\\}|^\\s*(\\s*/[*].*[*]/\\s*)*\\)|^\\s*(public|private|protected):\\s*$|^\\s*@(public|private|protected)\\s*$'),
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
let mode = new JSONMode();
|
||||
let model = createTextModel(
|
||||
[
|
||||
'{',
|
||||
' "scripts: {"',
|
||||
' "watch": "a {"',
|
||||
' "build{": "b"',
|
||||
' "tasks": []',
|
||||
' "tasks": ["a"]',
|
||||
' "}"',
|
||||
'"}"'
|
||||
].join('\n'),
|
||||
{
|
||||
tabSize: 2,
|
||||
indentSize: 2
|
||||
},
|
||||
mode.getLanguageIdentifier()
|
||||
);
|
||||
|
||||
withTestCodeEditor(null, { model: model, autoIndent: true }, (editor, cursor) => {
|
||||
moveTo(cursor, 3, 19, false);
|
||||
assertCursor(cursor, new Selection(3, 19, 3, 19));
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '\n' }, 'keyboard');
|
||||
assert.deepEqual(model.getLineContent(4), ' ');
|
||||
|
||||
moveTo(cursor, 5, 18, false);
|
||||
assertCursor(cursor, new Selection(5, 18, 5, 18));
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '\n' }, 'keyboard');
|
||||
assert.deepEqual(model.getLineContent(6), ' ');
|
||||
|
||||
moveTo(cursor, 7, 15, false);
|
||||
assertCursor(cursor, new Selection(7, 15, 7, 15));
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '\n' }, 'keyboard');
|
||||
assert.deepEqual(model.getLineContent(8), ' ');
|
||||
assert.deepEqual(model.getLineContent(9), ' ]');
|
||||
|
||||
moveTo(cursor, 10, 18, false);
|
||||
assertCursor(cursor, new Selection(10, 18, 10, 18));
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '\n' }, 'keyboard');
|
||||
assert.deepEqual(model.getLineContent(11), ' ]');
|
||||
});
|
||||
|
||||
model.dispose();
|
||||
mode.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
interface ICursorOpts {
|
||||
|
|
Loading…
Reference in a new issue