mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)
This commit is contained in:
@@ -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 {
|
||||
@@ -4595,6 +4664,34 @@ suite('autoClosingPairs', () => {
|
||||
mode.dispose();
|
||||
});
|
||||
|
||||
test('issue #78527 - does not close quote on odd count', () => {
|
||||
let mode = new AutoClosingMode();
|
||||
usingCursor({
|
||||
text: [
|
||||
'std::cout << \'"\' << entryMap'
|
||||
],
|
||||
languageIdentifier: mode.getLanguageIdentifier()
|
||||
}, (model, cursor) => {
|
||||
cursor.setSelections('test', [new Selection(1, 29, 1, 29)]);
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '[' }, 'keyboard');
|
||||
assert.strictEqual(model.getLineContent(1), 'std::cout << \'"\' << entryMap[]');
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '"' }, 'keyboard');
|
||||
assert.strictEqual(model.getLineContent(1), 'std::cout << \'"\' << entryMap[""]');
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: 'a' }, 'keyboard');
|
||||
assert.strictEqual(model.getLineContent(1), 'std::cout << \'"\' << entryMap["a"]');
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '"' }, 'keyboard');
|
||||
assert.strictEqual(model.getLineContent(1), 'std::cout << \'"\' << entryMap["a"]');
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: ']' }, 'keyboard');
|
||||
assert.strictEqual(model.getLineContent(1), 'std::cout << \'"\' << entryMap["a"]');
|
||||
});
|
||||
mode.dispose();
|
||||
});
|
||||
|
||||
test('issue #15825: accents on mac US intl keyboard', () => {
|
||||
let mode = new AutoClosingMode();
|
||||
usingCursor({
|
||||
|
||||
@@ -608,6 +608,46 @@ suite('Editor Model - TextModel', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('issue #62143: Broken indentation detection', () => {
|
||||
// works before the fix
|
||||
assertGuess(true, 2, [
|
||||
'x',
|
||||
'x',
|
||||
' x',
|
||||
' x'
|
||||
]);
|
||||
|
||||
// works before the fix
|
||||
assertGuess(true, 2, [
|
||||
'x',
|
||||
' - item2',
|
||||
' - item3'
|
||||
]);
|
||||
|
||||
// works before the fix
|
||||
testGuessIndentation(true, 2, true, 2, [
|
||||
'x x',
|
||||
' x',
|
||||
' x',
|
||||
]);
|
||||
|
||||
// fails before the fix
|
||||
// empty space inline breaks the indentation guess
|
||||
testGuessIndentation(true, 2, true, 2, [
|
||||
'x x',
|
||||
' x',
|
||||
' x',
|
||||
' x'
|
||||
]);
|
||||
|
||||
testGuessIndentation(true, 2, true, 2, [
|
||||
'<!--test1.md -->',
|
||||
'- item1',
|
||||
' - item2',
|
||||
' - item3'
|
||||
]);
|
||||
});
|
||||
|
||||
test('validatePosition', () => {
|
||||
|
||||
let m = TextModel.createFromString('line one\nline two');
|
||||
|
||||
@@ -109,9 +109,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #0000ff;text-decoration: underline;">world!</span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
@@ -122,9 +122,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #0000ff;text-decoration: underline;">w</span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
@@ -135,9 +135,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
);
|
||||
@@ -147,9 +147,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">iao</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
);
|
||||
@@ -158,9 +158,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 4, 11, 4),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
);
|
||||
@@ -170,7 +170,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
);
|
||||
@@ -193,6 +193,88 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
].join('')
|
||||
);
|
||||
});
|
||||
test('tokenizeLineToHTML handle spaces #35954', () => {
|
||||
const text = ' Ciao hello world!';
|
||||
const lineTokens = new ViewLineTokens([
|
||||
new ViewLineToken(
|
||||
2,
|
||||
(
|
||||
(1 << MetadataConsts.FOREGROUND_OFFSET)
|
||||
) >>> 0
|
||||
),
|
||||
new ViewLineToken(
|
||||
6,
|
||||
(
|
||||
(3 << MetadataConsts.FOREGROUND_OFFSET)
|
||||
| ((FontStyle.Bold | FontStyle.Italic) << MetadataConsts.FONT_STYLE_OFFSET)
|
||||
) >>> 0
|
||||
),
|
||||
new ViewLineToken(
|
||||
9,
|
||||
(
|
||||
(1 << MetadataConsts.FOREGROUND_OFFSET)
|
||||
) >>> 0
|
||||
),
|
||||
new ViewLineToken(
|
||||
14,
|
||||
(
|
||||
(4 << MetadataConsts.FOREGROUND_OFFSET)
|
||||
) >>> 0
|
||||
),
|
||||
new ViewLineToken(
|
||||
15,
|
||||
(
|
||||
(1 << MetadataConsts.FOREGROUND_OFFSET)
|
||||
) >>> 0
|
||||
),
|
||||
new ViewLineToken(
|
||||
21,
|
||||
(
|
||||
(5 << MetadataConsts.FOREGROUND_OFFSET)
|
||||
| ((FontStyle.Underline) << MetadataConsts.FONT_STYLE_OFFSET)
|
||||
) >>> 0
|
||||
)
|
||||
]);
|
||||
const colorMap = [null!, '#000000', '#ffffff', '#ff0000', '#00ff00', '#0000ff'];
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 21, 4),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #000000;">  </span>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
|
||||
'<span style="color: #000000;">   </span>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #0000ff;text-decoration: underline;">world!</span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 17, 4),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #000000;">  </span>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
|
||||
'<span style="color: #000000;">   </span>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
'<span style="color: #0000ff;text-decoration: underline;">wo</span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 3, 4),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #000000;">  </span>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">C</span>',
|
||||
'</div>'
|
||||
].join('')
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -114,6 +114,11 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
|
||||
assert.equal(mapper!.getWrappedLinesIndent(), ' \t');
|
||||
});
|
||||
|
||||
test('issue #75494: surrogate pairs', () => {
|
||||
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
|
||||
assertLineMapping(factory, 4, 49, '🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇|👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬', WrappingIndent.Same);
|
||||
});
|
||||
|
||||
test('CharacterHardWrappingLineMapper - WrappingIndent.DeepIndent', () => {
|
||||
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
|
||||
let mapper = assertLineMapping(factory, 4, 26, ' W e A r e T e s t |i n g D e |e p I n d |e n t a t |i o n', WrappingIndent.DeepIndent);
|
||||
|
||||
Reference in New Issue
Block a user