Merge from vscode 27ada910e121e23a6d95ecca9cae595fb98ab568

This commit is contained in:
ADS Merger
2020-04-30 00:53:43 +00:00
parent 87e5239713
commit 93f35ca321
413 changed files with 7190 additions and 8756 deletions

View File

@@ -1428,6 +1428,28 @@ suite('Editor Controller - Regression tests', () => {
model.dispose();
});
test('issue #95591: Unindenting moves cursor to beginning of line', () => {
let model = createTextModel(
[
' '
].join('\n')
);
withTestCodeEditor(null, {
model: model,
useTabStops: false
}, (editor, cursor) => {
moveTo(cursor, 1, 9, false);
assertCursor(cursor, new Selection(1, 9, 1, 9));
CoreEditingCommands.Outdent.runEditorCommand(null, editor, null);
assert.equal(model.getLineContent(1), ' ');
assertCursor(cursor, new Selection(1, 5, 1, 5));
});
model.dispose();
});
test('Bug #16657: [editor] Tab on empty line of zero indentation moves cursor to position (1,1)', () => {
let model = createTextModel(
[

View File

@@ -8,7 +8,7 @@ import { MultilineTokens2, SparseEncodedTokens, TokensStore2 } from 'vs/editor/c
import { Range } from 'vs/editor/common/core/range';
import { TextModel } from 'vs/editor/common/model/textModel';
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
import { MetadataConsts, TokenMetadata } from 'vs/editor/common/modes';
import { MetadataConsts, TokenMetadata, FontStyle } from 'vs/editor/common/modes';
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
import { LineTokens } from 'vs/editor/common/core/lineTokens';
@@ -387,4 +387,50 @@ suite('TokensStore', () => {
const lineTokens = store.addSemanticTokens(36451, new LineTokens(new Uint32Array([60, 1]), ` if (flags & ModifierFlags.Ambient) {`));
assert.equal(lineTokens.getCount(), 7);
});
test('issue #95949: Identifiers are colored in bold when targetting keywords', () => {
function createTMMetadata(foreground: number, fontStyle: number, languageId: number): number {
return (
(languageId << MetadataConsts.LANGUAGEID_OFFSET)
| (fontStyle << MetadataConsts.FONT_STYLE_OFFSET)
| (foreground << MetadataConsts.FOREGROUND_OFFSET)
) >>> 0;
}
function toArr(lineTokens: LineTokens): number[] {
let r: number[] = [];
for (let i = 0; i < lineTokens.getCount(); i++) {
r.push(lineTokens.getEndOffset(i));
r.push(lineTokens.getMetadata(i));
}
return r;
}
const store = new TokensStore2();
store.set([
new MultilineTokens2(1, new SparseEncodedTokens(new Uint32Array([
0, 6, 11, (1 << MetadataConsts.FOREGROUND_OFFSET) | MetadataConsts.SEMANTIC_USE_FOREGROUND,
])))
], true);
const lineTokens = store.addSemanticTokens(1, new LineTokens(new Uint32Array([
5, createTMMetadata(5, FontStyle.Bold, 53),
14, createTMMetadata(1, FontStyle.None, 53),
17, createTMMetadata(6, FontStyle.None, 53),
18, createTMMetadata(1, FontStyle.None, 53),
]), `const hello = 123;`));
const actual = toArr(lineTokens);
assert.deepEqual(actual, [
5, createTMMetadata(5, FontStyle.Bold, 53),
6, createTMMetadata(1, FontStyle.None, 53),
11, createTMMetadata(1, FontStyle.None, 53),
14, createTMMetadata(1, FontStyle.None, 53),
17, createTMMetadata(6, FontStyle.None, 53),
18, createTMMetadata(1, FontStyle.None, 53)
]);
});
});

View File

@@ -13,7 +13,7 @@ import { Selection } from 'vs/editor/common/core/selection';
import { createStringBuilder } from 'vs/editor/common/core/stringBuilder';
import { DefaultEndOfLine } from 'vs/editor/common/model';
import { createTextBuffer } from 'vs/editor/common/model/textModel';
import { ModelServiceImpl, MAINTAIN_UNDO_REDO_STACK } from 'vs/editor/common/services/modelServiceImpl';
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
@@ -35,7 +35,7 @@ suite('ModelService', () => {
configService.setUserConfiguration('files', { 'eol': '\r\n' }, URI.file(platform.isWindows ? 'c:\\myroot' : '/myroot'));
const dialogService = new TestDialogService();
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService(), new UndoRedoService(dialogService, new TestNotificationService()), dialogService);
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService(), new UndoRedoService(dialogService, new TestNotificationService()));
});
teardown(() => {
@@ -310,44 +310,42 @@ suite('ModelService', () => {
assertComputeEdits(file1, file2);
});
if (MAINTAIN_UNDO_REDO_STACK) {
test('maintains undo for same resource and same content', () => {
const resource = URI.parse('file://test.txt');
test('maintains undo for same resource and same content', () => {
const resource = URI.parse('file://test.txt');
// create a model
const model1 = modelService.createModel('text', null, resource);
// make an edit
model1.pushEditOperations(null, [{ range: new Range(1, 5, 1, 5), text: '1' }], () => [new Selection(1, 5, 1, 5)]);
assert.equal(model1.getValue(), 'text1');
// dispose it
modelService.destroyModel(resource);
// create a model
const model1 = modelService.createModel('text', null, resource);
// make an edit
model1.pushEditOperations(null, [{ range: new Range(1, 5, 1, 5), text: '1' }], () => [new Selection(1, 5, 1, 5)]);
assert.equal(model1.getValue(), 'text1');
// dispose it
modelService.destroyModel(resource);
// create a new model with the same content
const model2 = modelService.createModel('text1', null, resource);
// undo
model2.undo();
assert.equal(model2.getValue(), 'text');
});
// create a new model with the same content
const model2 = modelService.createModel('text1', null, resource);
// undo
model2.undo();
assert.equal(model2.getValue(), 'text');
});
test('maintains version id and alternative version id for same resource and same content', () => {
const resource = URI.parse('file://test.txt');
test('maintains version id and alternative version id for same resource and same content', () => {
const resource = URI.parse('file://test.txt');
// create a model
const model1 = modelService.createModel('text', null, resource);
// make an edit
model1.pushEditOperations(null, [{ range: new Range(1, 5, 1, 5), text: '1' }], () => [new Selection(1, 5, 1, 5)]);
assert.equal(model1.getValue(), 'text1');
const versionId = model1.getVersionId();
const alternativeVersionId = model1.getAlternativeVersionId();
// dispose it
modelService.destroyModel(resource);
// create a model
const model1 = modelService.createModel('text', null, resource);
// make an edit
model1.pushEditOperations(null, [{ range: new Range(1, 5, 1, 5), text: '1' }], () => [new Selection(1, 5, 1, 5)]);
assert.equal(model1.getValue(), 'text1');
const versionId = model1.getVersionId();
const alternativeVersionId = model1.getAlternativeVersionId();
// dispose it
modelService.destroyModel(resource);
// create a new model with the same content
const model2 = modelService.createModel('text1', null, resource);
assert.equal(model2.getVersionId(), versionId);
assert.equal(model2.getAlternativeVersionId(), alternativeVersionId);
});
}
// create a new model with the same content
const model2 = modelService.createModel('text1', null, resource);
assert.equal(model2.getVersionId(), versionId);
assert.equal(model2.getAlternativeVersionId(), alternativeVersionId);
});
test('does not maintain undo for same resource and different content', () => {
const resource = URI.parse('file://test.txt');

View File

@@ -147,7 +147,7 @@ suite('Editor ViewModel - MonospaceLineBreaksComputer', () => {
test('MonospaceLineBreaksComputer incremental 1', () => {
let factory = new MonospaceLineBreaksComputerFactory(EditorOptions.wordWrapBreakBeforeCharacters.defaultValue, EditorOptions.wordWrapBreakAfterCharacters.defaultValue);
const factory = new MonospaceLineBreaksComputerFactory(EditorOptions.wordWrapBreakBeforeCharacters.defaultValue, EditorOptions.wordWrapBreakAfterCharacters.defaultValue);
assertIncrementalLineBreaks(
factory, 'just some text and more', 4,
@@ -203,6 +203,17 @@ suite('Editor ViewModel - MonospaceLineBreaksComputer', () => {
);
});
test('issue #95686: CRITICAL: loop forever on the monospaceLineBreaksComputer', () => {
const factory = new MonospaceLineBreaksComputerFactory(EditorOptions.wordWrapBreakBeforeCharacters.defaultValue, EditorOptions.wordWrapBreakAfterCharacters.defaultValue);
assertIncrementalLineBreaks(
factory,
' <tr dmx-class:table-danger="(alt <= 50)" dmx-class:table-warning="(alt <= 200)" dmx-class:table-primary="(alt <= 400)" dmx-class:table-info="(alt <= 800)" dmx-class:table-success="(alt >= 400)">',
4,
179, ' <tr dmx-class:table-danger="(alt <= 50)" dmx-class:table-warning="(alt <= 200)" dmx-class:table-primary="(alt <= 400)" dmx-class:table-info="(alt <= 800)" |dmx-class:table-success="(alt >= 400)">',
1, ' | | | | | |<|t|r| |d|m|x|-|c|l|a|s|s|:|t|a|b|l|e|-|d|a|n|g|e|r|=|"|(|a|l|t| |<|=| |5|0|)|"| |d|m|x|-|c|l|a|s|s|:|t|a|b|l|e|-|w|a|r|n|i|n|g|=|"|(|a|l|t| |<|=| |2|0|0|)|"| |d|m|x|-|c|l|a|s|s|:|t|a|b|l|e|-|p|r|i|m|a|r|y|=|"|(|a|l|t| |<|=| |4|0|0|)|"| |d|m|x|-|c|l|a|s|s|:|t|a|b|l|e|-|i|n|f|o|=|"|(|a|l|t| |<|=| |8|0|0|)|"| |d|m|x|-|c|l|a|s|s|:|t|a|b|l|e|-|s|u|c|c|e|s|s|=|"|(|a|l|t| |>|=| |4|0|0|)|"|>',
WrappingIndent.Same
);
});
test('MonospaceLineBreaksComputer - CJK and Kinsoku Shori', () => {
let factory = new MonospaceLineBreaksComputerFactory('(', '\t)');