mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -1494,6 +1494,25 @@ suite('Editor Controller - Regression tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #74722: Pasting whole line does not replace selection', () => {
|
||||
usingCursor({
|
||||
text: [
|
||||
'line1',
|
||||
'line sel 2',
|
||||
'line3'
|
||||
],
|
||||
}, (model, cursor) => {
|
||||
cursor.setSelections('test', [new Selection(2, 6, 2, 9)]);
|
||||
|
||||
cursorCommand(cursor, H.Paste, { text: 'line1\n', pasteOnNewLine: true });
|
||||
|
||||
assert.equal(model.getLineContent(1), 'line1');
|
||||
assert.equal(model.getLineContent(2), 'line line1');
|
||||
assert.equal(model.getLineContent(3), ' 2');
|
||||
assert.equal(model.getLineContent(4), 'line3');
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #4996: Multiple cursor paste pastes contents of all cursors', () => {
|
||||
usingCursor({
|
||||
text: [
|
||||
@@ -2572,7 +2591,37 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
'',
|
||||
' }',
|
||||
].join('\n'));
|
||||
assertCursor(cursor, new Position(5, 1));
|
||||
assertCursor(cursor, new Position(4, 1));
|
||||
});
|
||||
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('issue #40695: maintain cursor position when copying lines using ctrl+c, ctrl+v', () => {
|
||||
let model = createTextModel(
|
||||
[
|
||||
' function f() {',
|
||||
' // I\'m gonna copy this line',
|
||||
' // Another line',
|
||||
' return 3;',
|
||||
' }',
|
||||
].join('\n')
|
||||
);
|
||||
|
||||
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
|
||||
|
||||
editor.setSelections([new Selection(4, 10, 4, 10)]);
|
||||
cursorCommand(cursor, H.Paste, { text: ' // I\'m gonna copy this line\n', pasteOnNewLine: true });
|
||||
|
||||
assert.equal(model.getValue(), [
|
||||
' function f() {',
|
||||
' // I\'m gonna copy this line',
|
||||
' // Another line',
|
||||
' // I\'m gonna copy this line',
|
||||
' return 3;',
|
||||
' }',
|
||||
].join('\n'));
|
||||
assertCursor(cursor, new Position(5, 10));
|
||||
});
|
||||
|
||||
model.dispose();
|
||||
@@ -4822,6 +4871,32 @@ suite('autoClosingPairs', () => {
|
||||
mode.dispose();
|
||||
});
|
||||
|
||||
test('issue #53357: Over typing ignores characters after backslash', () => {
|
||||
let mode = new AutoClosingMode();
|
||||
usingCursor({
|
||||
text: [
|
||||
'console.log();'
|
||||
],
|
||||
languageIdentifier: mode.getLanguageIdentifier()
|
||||
}, (model, cursor) => {
|
||||
|
||||
cursor.setSelections('test', [new Selection(1, 13, 1, 13)]);
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '\'' }, 'keyboard');
|
||||
assert.equal(model.getValue(), 'console.log(\'\');');
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: 'it' }, 'keyboard');
|
||||
assert.equal(model.getValue(), 'console.log(\'it\');');
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '\\' }, 'keyboard');
|
||||
assert.equal(model.getValue(), 'console.log(\'it\\\');');
|
||||
|
||||
cursorCommand(cursor, H.Type, { text: '\'' }, 'keyboard');
|
||||
assert.equal(model.getValue(), 'console.log(\'it\\\'\'\');');
|
||||
});
|
||||
mode.dispose();
|
||||
});
|
||||
|
||||
test('issue #2773: Accents (´`¨^, others?) are inserted in the wrong position (Mac)', () => {
|
||||
let mode = new AutoClosingMode();
|
||||
usingCursor({
|
||||
|
||||
@@ -86,8 +86,14 @@ function doCreateTest(description: string, inputStr: string, expectedStr: string
|
||||
let model = new SingleLineTestModel('some text');
|
||||
|
||||
const textAreaInputHost: ITextAreaInputHost = {
|
||||
getPlainTextToCopy: (): string => '',
|
||||
getHTMLToCopy: (): string => '',
|
||||
getDataToCopy: () => {
|
||||
return {
|
||||
isFromEmptySelection: false,
|
||||
multicursorText: null,
|
||||
text: '',
|
||||
html: undefined
|
||||
};
|
||||
},
|
||||
getScreenReaderContent: (currentState: TextAreaState): TextAreaState => {
|
||||
|
||||
if (browser.isIPad) {
|
||||
|
||||
@@ -14,10 +14,10 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
|
||||
export class TestCodeEditorService extends AbstractCodeEditorService {
|
||||
public lastInput?: IResourceInput;
|
||||
public getActiveCodeEditor(): ICodeEditor | undefined { return undefined; }
|
||||
public openCodeEditor(input: IResourceInput, _source: ICodeEditor | undefined, _sideBySide?: boolean): Promise<ICodeEditor | undefined> {
|
||||
public getActiveCodeEditor(): ICodeEditor | null { return null; }
|
||||
public openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null> {
|
||||
this.lastInput = input;
|
||||
return Promise.resolve(undefined);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
public registerDecorationType(key: string, options: IDecorationRenderOptions, parentTypeKey?: string): void { }
|
||||
public removeDecorationType(key: string): void { }
|
||||
|
||||
@@ -15,12 +15,12 @@ import { TestTheme, TestThemeService } from 'vs/platform/theme/test/common/testT
|
||||
const themeServiceMock = new TestThemeService();
|
||||
|
||||
export class TestCodeEditorServiceImpl extends CodeEditorServiceImpl {
|
||||
getActiveCodeEditor(): ICodeEditor | undefined {
|
||||
return undefined;
|
||||
getActiveCodeEditor(): ICodeEditor | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
openCodeEditor(input: IResourceInput, source: ICodeEditor | undefined, sideBySide?: boolean): Promise<ICodeEditor | undefined> {
|
||||
return Promise.resolve(undefined);
|
||||
openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ export class TestCodeEditor extends CodeEditorWidget implements editorBrowser.IC
|
||||
public getCursor(): Cursor | undefined {
|
||||
return this._modelData ? this._modelData.cursor : undefined;
|
||||
}
|
||||
public registerAndInstantiateContribution<T extends editorCommon.IEditorContribution>(ctor: any): T {
|
||||
public registerAndInstantiateContribution<T extends editorCommon.IEditorContribution>(id: string, ctor: any): T {
|
||||
let r = <T>this._instantiationService.createInstance(ctor, this);
|
||||
this._contributions[r.getId()] = r;
|
||||
this._contributions[id] = r;
|
||||
return r;
|
||||
}
|
||||
public dispose() {
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { RGBA8 } from 'vs/editor/common/core/rgba';
|
||||
import { Constants } from 'vs/editor/common/view/minimapCharRenderer';
|
||||
import { getOrCreateMinimapCharRenderer } from 'vs/editor/common/view/runtimeMinimapCharRenderer';
|
||||
import { MinimapCharRendererFactory } from 'vs/editor/test/common/view/minimapCharRendererFactory';
|
||||
import { Constants } from 'vs/editor/browser/viewParts/minimap/minimapCharSheet';
|
||||
import { MinimapCharRendererFactory } from 'vs/editor/browser/viewParts/minimap/minimapCharRendererFactory';
|
||||
|
||||
suite('MinimapCharRenderer', () => {
|
||||
|
||||
@@ -75,11 +74,11 @@ suite('MinimapCharRenderer', () => {
|
||||
|
||||
test('letter d @ 2x', () => {
|
||||
setSampleData('d'.charCodeAt(0), sampleD);
|
||||
let renderer = MinimapCharRendererFactory.create(sampleData!);
|
||||
let renderer = MinimapCharRendererFactory.createFromSampleData(sampleData!, 2);
|
||||
|
||||
let background = new RGBA8(0, 0, 0, 255);
|
||||
let color = new RGBA8(255, 255, 255, 255);
|
||||
let imageData = createFakeImageData(Constants.x2_CHAR_WIDTH, Constants.x2_CHAR_HEIGHT);
|
||||
let imageData = createFakeImageData(Constants.BASE_CHAR_WIDTH * 2, Constants.BASE_CHAR_HEIGHT * 2);
|
||||
// set the background color
|
||||
for (let i = 0, len = imageData.data.length / 4; i < len; i++) {
|
||||
imageData.data[4 * i + 0] = background.r;
|
||||
@@ -87,55 +86,28 @@ suite('MinimapCharRenderer', () => {
|
||||
imageData.data[4 * i + 2] = background.b;
|
||||
imageData.data[4 * i + 3] = 255;
|
||||
}
|
||||
renderer.x2RenderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, false);
|
||||
renderer.renderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, false);
|
||||
|
||||
let actual: number[] = [];
|
||||
for (let i = 0; i < imageData.data.length; i++) {
|
||||
actual[i] = imageData.data[i];
|
||||
}
|
||||
|
||||
assert.deepEqual(actual, [
|
||||
0x00, 0x00, 0x00, 0xFF, 0x6D, 0x6D, 0x6D, 0xFF,
|
||||
0xBB, 0xBB, 0xBB, 0xFF, 0xBE, 0xBE, 0xBE, 0xFF,
|
||||
0x94, 0x94, 0x94, 0xFF, 0x7E, 0x7E, 0x7E, 0xFF,
|
||||
0xB1, 0xB1, 0xB1, 0xFF, 0xBB, 0xBB, 0xBB, 0xFF,
|
||||
]);
|
||||
});
|
||||
|
||||
test('letter d @ 2x at runtime', () => {
|
||||
let renderer = getOrCreateMinimapCharRenderer();
|
||||
|
||||
let background = new RGBA8(0, 0, 0, 255);
|
||||
let color = new RGBA8(255, 255, 255, 255);
|
||||
let imageData = createFakeImageData(Constants.x2_CHAR_WIDTH, Constants.x2_CHAR_HEIGHT);
|
||||
// set the background color
|
||||
for (let i = 0, len = imageData.data.length / 4; i < len; i++) {
|
||||
imageData.data[4 * i + 0] = background.r;
|
||||
imageData.data[4 * i + 1] = background.g;
|
||||
imageData.data[4 * i + 2] = background.b;
|
||||
imageData.data[4 * i + 3] = 255;
|
||||
}
|
||||
|
||||
renderer.x2RenderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, false);
|
||||
|
||||
let actual: number[] = [];
|
||||
for (let i = 0; i < imageData.data.length; i++) {
|
||||
actual[i] = imageData.data[i];
|
||||
}
|
||||
assert.deepEqual(actual, [
|
||||
0x00, 0x00, 0x00, 0xFF, 0x6D, 0x6D, 0x6D, 0xFF,
|
||||
0xBB, 0xBB, 0xBB, 0xFF, 0xBE, 0xBE, 0xBE, 0xFF,
|
||||
0x94, 0x94, 0x94, 0xFF, 0x7E, 0x7E, 0x7E, 0xFF,
|
||||
0xB1, 0xB1, 0xB1, 0xFF, 0xBB, 0xBB, 0xBB, 0xFF,
|
||||
0x2E, 0x2E, 0x2E, 0xFF, 0xAD, 0xAD, 0xAD, 0xFF,
|
||||
0xC6, 0xC6, 0xC6, 0xFF, 0xC8, 0xC8, 0xC8, 0xFF,
|
||||
0xC1, 0xC1, 0xC1, 0xFF, 0xCC, 0xCC, 0xCC, 0xFF,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF,
|
||||
]);
|
||||
});
|
||||
|
||||
test('letter d @ 1x', () => {
|
||||
setSampleData('d'.charCodeAt(0), sampleD);
|
||||
let renderer = MinimapCharRendererFactory.create(sampleData!);
|
||||
let renderer = MinimapCharRendererFactory.createFromSampleData(sampleData!, 1);
|
||||
|
||||
let background = new RGBA8(0, 0, 0, 255);
|
||||
let color = new RGBA8(255, 255, 255, 255);
|
||||
let imageData = createFakeImageData(Constants.x1_CHAR_WIDTH, Constants.x1_CHAR_HEIGHT);
|
||||
let imageData = createFakeImageData(Constants.BASE_CHAR_WIDTH, Constants.BASE_CHAR_HEIGHT);
|
||||
// set the background color
|
||||
for (let i = 0, len = imageData.data.length / 4; i < len; i++) {
|
||||
imageData.data[4 * i + 0] = background.r;
|
||||
@@ -144,42 +116,17 @@ suite('MinimapCharRenderer', () => {
|
||||
imageData.data[4 * i + 3] = 255;
|
||||
}
|
||||
|
||||
renderer.x1RenderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, false);
|
||||
renderer.renderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, false);
|
||||
|
||||
let actual: number[] = [];
|
||||
for (let i = 0; i < imageData.data.length; i++) {
|
||||
actual[i] = imageData.data[i];
|
||||
}
|
||||
|
||||
assert.deepEqual(actual, [
|
||||
0x55, 0x55, 0x55, 0xFF,
|
||||
0x93, 0x93, 0x93, 0xFF,
|
||||
0xCB, 0xCB, 0xCB, 0xFF,
|
||||
0x82, 0x82, 0x82, 0xFF,
|
||||
]);
|
||||
});
|
||||
|
||||
test('letter d @ 1x at runtime', () => {
|
||||
let renderer = getOrCreateMinimapCharRenderer();
|
||||
|
||||
let background = new RGBA8(0, 0, 0, 255);
|
||||
let color = new RGBA8(255, 255, 255, 255);
|
||||
let imageData = createFakeImageData(Constants.x1_CHAR_WIDTH, Constants.x1_CHAR_HEIGHT);
|
||||
// set the background color
|
||||
for (let i = 0, len = imageData.data.length / 4; i < len; i++) {
|
||||
imageData.data[4 * i + 0] = background.r;
|
||||
imageData.data[4 * i + 1] = background.g;
|
||||
imageData.data[4 * i + 2] = background.b;
|
||||
imageData.data[4 * i + 3] = 255;
|
||||
}
|
||||
|
||||
renderer.x1RenderChar(imageData, 0, 0, 'd'.charCodeAt(0), color, background, false);
|
||||
|
||||
let actual: number[] = [];
|
||||
for (let i = 0; i < imageData.data.length; i++) {
|
||||
actual[i] = imageData.data[i];
|
||||
}
|
||||
assert.deepEqual(actual, [
|
||||
0x55, 0x55, 0x55, 0xFF,
|
||||
0x93, 0x93, 0x93, 0xFF,
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -4,31 +4,21 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { RGBA8 } from 'vs/editor/common/core/rgba';
|
||||
import { Constants, MinimapCharRenderer } from 'vs/editor/common/view/minimapCharRenderer';
|
||||
import { getOrCreateMinimapCharRenderer } from 'vs/editor/common/view/runtimeMinimapCharRenderer';
|
||||
import { MinimapCharRendererFactory } from 'vs/editor/test/common/view/minimapCharRendererFactory';
|
||||
import { MinimapCharRenderer } from 'vs/editor/browser/viewParts/minimap/minimapCharRenderer';
|
||||
import { Constants } from 'vs/editor/browser/viewParts/minimap/minimapCharSheet';
|
||||
import { MinimapCharRendererFactory } from 'vs/editor/browser/viewParts/minimap/minimapCharRendererFactory';
|
||||
|
||||
let canvas = <HTMLCanvasElement>document.getElementById('my-canvas');
|
||||
let ctx = canvas.getContext('2d')!;
|
||||
|
||||
canvas.style.height = 100 + 'px';
|
||||
canvas.height = 100;
|
||||
|
||||
canvas.width = Constants.CHAR_COUNT * Constants.SAMPLED_CHAR_WIDTH;
|
||||
canvas.style.width = (Constants.CHAR_COUNT * Constants.SAMPLED_CHAR_WIDTH) + 'px';
|
||||
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.font = 'bold 16px monospace';
|
||||
for (let chCode = Constants.START_CH_CODE; chCode <= Constants.END_CH_CODE; chCode++) {
|
||||
ctx.fillText(String.fromCharCode(chCode), (chCode - Constants.START_CH_CODE) * Constants.SAMPLED_CHAR_WIDTH, Constants.SAMPLED_CHAR_HEIGHT);
|
||||
}
|
||||
|
||||
let sampleData = ctx.getImageData(0, 4, Constants.SAMPLED_CHAR_WIDTH * Constants.CHAR_COUNT, Constants.SAMPLED_CHAR_HEIGHT);
|
||||
let minimapCharRenderer = MinimapCharRendererFactory.create(sampleData.data);
|
||||
let sampleData = MinimapCharRendererFactory.createSampleData('monospace');
|
||||
let minimapCharRenderer1x = MinimapCharRendererFactory.createFromSampleData(sampleData.data, 1);
|
||||
let minimapCharRenderer2x = MinimapCharRendererFactory.createFromSampleData(sampleData.data, 2);
|
||||
let minimapCharRenderer4x = MinimapCharRendererFactory.createFromSampleData(sampleData.data, 4);
|
||||
let minimapCharRenderer6x = MinimapCharRendererFactory.createFromSampleData(sampleData.data, 6);
|
||||
|
||||
renderImageData(sampleData, 10, 100);
|
||||
renderMinimapCharRenderer(minimapCharRenderer, 400);
|
||||
renderMinimapCharRenderer(getOrCreateMinimapCharRenderer(), 600);
|
||||
renderMinimapCharRenderer(minimapCharRenderer1x, 400, 1);
|
||||
renderMinimapCharRenderer(minimapCharRenderer2x, 500, 2);
|
||||
renderMinimapCharRenderer(minimapCharRenderer4x, 600, 4);
|
||||
renderMinimapCharRenderer(minimapCharRenderer6x, 750, 8);
|
||||
|
||||
function createFakeImageData(width: number, height: number): ImageData {
|
||||
return {
|
||||
@@ -38,13 +28,15 @@ function createFakeImageData(width: number, height: number): ImageData {
|
||||
};
|
||||
}
|
||||
|
||||
function renderMinimapCharRenderer(minimapCharRenderer: MinimapCharRenderer, y: number): void {
|
||||
|
||||
function renderMinimapCharRenderer(minimapCharRenderer: MinimapCharRenderer, y: number, scale: number): void {
|
||||
let background = new RGBA8(0, 0, 0, 255);
|
||||
let color = new RGBA8(255, 255, 255, 255);
|
||||
|
||||
{
|
||||
let x2 = createFakeImageData(Constants.x2_CHAR_WIDTH * Constants.CHAR_COUNT, Constants.x2_CHAR_HEIGHT);
|
||||
let x2 = createFakeImageData(
|
||||
Constants.BASE_CHAR_WIDTH * scale * Constants.CHAR_COUNT,
|
||||
Constants.BASE_CHAR_HEIGHT * scale
|
||||
);
|
||||
// set the background color
|
||||
for (let i = 0, len = x2.data.length / 4; i < len; i++) {
|
||||
x2.data[4 * i + 0] = background.r;
|
||||
@@ -54,67 +46,49 @@ function renderMinimapCharRenderer(minimapCharRenderer: MinimapCharRenderer, y:
|
||||
}
|
||||
let dx = 0;
|
||||
for (let chCode = Constants.START_CH_CODE; chCode <= Constants.END_CH_CODE; chCode++) {
|
||||
minimapCharRenderer.x2RenderChar(x2, dx, 0, chCode, color, background, false);
|
||||
dx += Constants.x2_CHAR_WIDTH;
|
||||
minimapCharRenderer.renderChar(x2, dx, 0, chCode, color, background, false);
|
||||
dx += Constants.BASE_CHAR_WIDTH * scale;
|
||||
}
|
||||
renderImageData(x2, 10, y);
|
||||
}
|
||||
{
|
||||
let x1 = createFakeImageData(Constants.x1_CHAR_WIDTH * Constants.CHAR_COUNT, Constants.x1_CHAR_HEIGHT);
|
||||
// set the background color
|
||||
for (let i = 0, len = x1.data.length / 4; i < len; i++) {
|
||||
x1.data[4 * i + 0] = background.r;
|
||||
x1.data[4 * i + 1] = background.g;
|
||||
x1.data[4 * i + 2] = background.b;
|
||||
x1.data[4 * i + 3] = 255;
|
||||
}
|
||||
let dx = 0;
|
||||
for (let chCode = Constants.START_CH_CODE; chCode <= Constants.END_CH_CODE; chCode++) {
|
||||
minimapCharRenderer.x1RenderChar(x1, dx, 0, chCode, color, background, false);
|
||||
dx += Constants.x1_CHAR_WIDTH;
|
||||
}
|
||||
renderImageData(x1, 10, y + 100);
|
||||
}
|
||||
}
|
||||
|
||||
(function () {
|
||||
let r = 'let x2Data = [', offset = 0;
|
||||
let r = 'let x2Data = [',
|
||||
offset = 0;
|
||||
for (let charIndex = 0; charIndex < Constants.CHAR_COUNT; charIndex++) {
|
||||
let charCode = charIndex + Constants.START_CH_CODE;
|
||||
r += '\n\n// ' + String.fromCharCode(charCode);
|
||||
|
||||
for (let i = 0; i < Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH; i++) {
|
||||
for (let i = 0; i < Constants.BASE_CHAR_HEIGHT * 2; i++) {
|
||||
if (i % 2 === 0) {
|
||||
r += '\n';
|
||||
}
|
||||
r += minimapCharRenderer.x2charData[offset] + ',';
|
||||
r += (minimapCharRenderer2x as any).charDataNormal[offset] + ',';
|
||||
offset++;
|
||||
}
|
||||
|
||||
}
|
||||
r += '\n\n]';
|
||||
console.log(r);
|
||||
})();
|
||||
|
||||
(function () {
|
||||
let r = 'let x1Data = [', offset = 0;
|
||||
let r = 'let x1Data = [',
|
||||
offset = 0;
|
||||
for (let charIndex = 0; charIndex < Constants.CHAR_COUNT; charIndex++) {
|
||||
let charCode = charIndex + Constants.START_CH_CODE;
|
||||
r += '\n\n// ' + String.fromCharCode(charCode);
|
||||
|
||||
for (let i = 0; i < Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH; i++) {
|
||||
for (let i = 0; i < Constants.BASE_CHAR_HEIGHT * Constants.BASE_CHAR_WIDTH; i++) {
|
||||
r += '\n';
|
||||
r += minimapCharRenderer.x1charData[offset] + ',';
|
||||
r += (minimapCharRenderer1x as any).charDataNormal[offset] + ',';
|
||||
offset++;
|
||||
}
|
||||
|
||||
}
|
||||
r += '\n\n]';
|
||||
console.log(r);
|
||||
})();
|
||||
|
||||
|
||||
|
||||
function renderImageData(imageData: ImageData, left: number, top: number): void {
|
||||
let output = '';
|
||||
let offset = 0;
|
||||
@@ -127,7 +101,8 @@ function renderImageData(imageData: ImageData, left: number, top: number): void
|
||||
let A = imageData.data[offset + 3];
|
||||
offset += 4;
|
||||
|
||||
output += `<div style="position:absolute;top:${PX_SIZE * i}px;left:${PX_SIZE * j}px;width:${PX_SIZE}px;height:${PX_SIZE}px;background:rgba(${R},${G},${B},${A / 256})"></div>`;
|
||||
output += `<div style="position:absolute;top:${PX_SIZE * i}px;left:${PX_SIZE *
|
||||
j}px;width:${PX_SIZE}px;height:${PX_SIZE}px;background:rgba(${R},${G},${B},${A / 256})"></div>`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +110,8 @@ function renderImageData(imageData: ImageData, left: number, top: number): void
|
||||
domNode.style.position = 'absolute';
|
||||
domNode.style.top = top + 'px';
|
||||
domNode.style.left = left + 'px';
|
||||
domNode.style.width = (imageData.width * PX_SIZE) + 'px';
|
||||
domNode.style.height = (imageData.height * PX_SIZE) + 'px';
|
||||
domNode.style.width = imageData.width * PX_SIZE + 'px';
|
||||
domNode.style.height = imageData.height * PX_SIZE + 'px';
|
||||
domNode.style.border = '1px solid #ccc';
|
||||
domNode.style.background = '#000000';
|
||||
domNode.innerHTML = output;
|
||||
|
||||
@@ -173,4 +173,60 @@ suite('CursorMove', () => {
|
||||
testColumnFromVisibleColumn('📚az', 4, 3, 4);
|
||||
testColumnFromVisibleColumn('📚az', 4, 4, 5);
|
||||
});
|
||||
});
|
||||
|
||||
test('toStatusbarColumn', () => {
|
||||
|
||||
function t(text: string, tabSize: number, column: number, expected: number): void {
|
||||
assert.equal(CursorColumns.toStatusbarColumn(text, column, tabSize), expected, `<<t('${text}', ${tabSize}, ${column}, ${expected})>>`);
|
||||
}
|
||||
|
||||
t(' spaces', 4, 1, 1);
|
||||
t(' spaces', 4, 2, 2);
|
||||
t(' spaces', 4, 3, 3);
|
||||
t(' spaces', 4, 4, 4);
|
||||
t(' spaces', 4, 5, 5);
|
||||
t(' spaces', 4, 6, 6);
|
||||
t(' spaces', 4, 7, 7);
|
||||
t(' spaces', 4, 8, 8);
|
||||
t(' spaces', 4, 9, 9);
|
||||
t(' spaces', 4, 10, 10);
|
||||
t(' spaces', 4, 11, 11);
|
||||
|
||||
t('\ttab', 4, 1, 1);
|
||||
t('\ttab', 4, 2, 5);
|
||||
t('\ttab', 4, 3, 6);
|
||||
t('\ttab', 4, 4, 7);
|
||||
t('\ttab', 4, 5, 8);
|
||||
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 1, 1);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 2, 2);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 3, 2);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 4, 3);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 5, 3);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 6, 4);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 7, 4);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 8, 5);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 9, 5);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 10, 6);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 11, 6);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 12, 7);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 13, 7);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 14, 8);
|
||||
t('𐌀𐌁𐌂𐌃𐌄𐌅𐌆', 4, 15, 8);
|
||||
|
||||
t('🎈🎈🎈🎈', 4, 1, 1);
|
||||
t('🎈🎈🎈🎈', 4, 2, 2);
|
||||
t('🎈🎈🎈🎈', 4, 3, 2);
|
||||
t('🎈🎈🎈🎈', 4, 4, 3);
|
||||
t('🎈🎈🎈🎈', 4, 5, 3);
|
||||
t('🎈🎈🎈🎈', 4, 6, 4);
|
||||
t('🎈🎈🎈🎈', 4, 7, 4);
|
||||
t('🎈🎈🎈🎈', 4, 8, 5);
|
||||
t('🎈🎈🎈🎈', 4, 9, 5);
|
||||
|
||||
t('何何何何', 4, 1, 1);
|
||||
t('何何何何', 4, 2, 2);
|
||||
t('何何何何', 4, 3, 3);
|
||||
t('何何何何', 4, 4, 4);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -87,9 +87,9 @@ suite('Editor Core - Range', () => {
|
||||
b = new Range(1, 1, 1, 4);
|
||||
assert.ok(Range.compareRangesUsingEnds(a, b) > 0, 'a.start = b.start, a.end > b.end');
|
||||
|
||||
a = new Range(1, 1, 5, 1);
|
||||
a = new Range(1, 2, 5, 1);
|
||||
b = new Range(1, 1, 1, 4);
|
||||
assert.ok(Range.compareRangesUsingEnds(a, b) > 0, 'a.start = b.start, a.end > b.end');
|
||||
assert.ok(Range.compareRangesUsingEnds(a, b) > 0, 'a.start > b.start, a.end > b.end');
|
||||
});
|
||||
|
||||
test('containsPosition', () => {
|
||||
|
||||
@@ -55,9 +55,10 @@ function assertDiff(originalLines: string[], modifiedLines: string[], expectedCh
|
||||
shouldComputeCharChanges,
|
||||
shouldPostProcessCharChanges,
|
||||
shouldIgnoreTrimWhitespace,
|
||||
shouldMakePrettyDiff: true
|
||||
shouldMakePrettyDiff: true,
|
||||
maxComputationTime: 0
|
||||
});
|
||||
let changes = diffComputer.computeDiff();
|
||||
let changes = diffComputer.computeDiff().changes;
|
||||
|
||||
let extracted: IChange[] = [];
|
||||
for (let i = 0; i < changes.length; i++) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CommonEditorConfiguration, IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IEditorOptions, EditorFontLigatures } from 'vs/editor/common/config/editorOptions';
|
||||
import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
|
||||
|
||||
@@ -33,6 +33,7 @@ export class TestConfiguration extends CommonEditorConfiguration {
|
||||
fontFamily: 'mockFont',
|
||||
fontWeight: 'normal',
|
||||
fontSize: 14,
|
||||
fontFeatureSettings: EditorFontLigatures.OFF,
|
||||
lineHeight: 19,
|
||||
letterSpacing: 1.5,
|
||||
isMonospace: true,
|
||||
|
||||
@@ -721,6 +721,20 @@ suite('TextModelSearch', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('issue #65281. \w should match line break.', () => {
|
||||
assertFindMatches(
|
||||
[
|
||||
'this/is{',
|
||||
'a test',
|
||||
'}',
|
||||
].join('\n'),
|
||||
'this/\\w*[^}]*', true, false, null,
|
||||
[
|
||||
[1, 1, 3, 1]
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
test('Simple find using unicode escape sequences', () => {
|
||||
assertFindMatches(
|
||||
regularText.join('\n'),
|
||||
|
||||
@@ -25,8 +25,8 @@ suite('TextModelWithTokens', () => {
|
||||
}
|
||||
return {
|
||||
range: a.range.toString(),
|
||||
open: a.open,
|
||||
close: a.close,
|
||||
open: a.open[0],
|
||||
close: a.close[0],
|
||||
isOpen: a.isOpen
|
||||
};
|
||||
}
|
||||
@@ -57,8 +57,8 @@ suite('TextModelWithTokens', () => {
|
||||
let ch = lineText.charAt(charIndex);
|
||||
if (charIsBracket[ch]) {
|
||||
expectedBrackets.push({
|
||||
open: openForChar[ch],
|
||||
close: closeForChar[ch],
|
||||
open: [openForChar[ch]],
|
||||
close: [closeForChar[ch]],
|
||||
isOpen: charIsOpenBracket[ch],
|
||||
range: new Range(lineIndex + 1, charIndex + 1, lineIndex + 1, charIndex + 2)
|
||||
});
|
||||
@@ -145,18 +145,18 @@ suite('TextModelWithTokens', () => {
|
||||
});
|
||||
});
|
||||
|
||||
function assertIsNotBracket(model: TextModel, lineNumber: number, column: number) {
|
||||
const match = model.matchBracket(new Position(lineNumber, column));
|
||||
assert.equal(match, null, 'is not matching brackets at ' + lineNumber + ', ' + column);
|
||||
}
|
||||
|
||||
function assertIsBracket(model: TextModel, testPosition: Position, expected: [Range, Range]): void {
|
||||
const actual = model.matchBracket(testPosition);
|
||||
assert.deepEqual(actual, expected, 'matches brackets at ' + testPosition);
|
||||
}
|
||||
|
||||
suite('TextModelWithTokens - bracket matching', () => {
|
||||
|
||||
function isNotABracket(model: TextModel, lineNumber: number, column: number) {
|
||||
let match = model.matchBracket(new Position(lineNumber, column));
|
||||
assert.equal(match, null, 'is not matching brackets at ' + lineNumber + ', ' + column);
|
||||
}
|
||||
|
||||
function isBracket2(model: TextModel, testPosition: Position, expected: [Range, Range]): void {
|
||||
let actual = model.matchBracket(testPosition);
|
||||
assert.deepEqual(actual, expected, 'matches brackets at ' + testPosition);
|
||||
}
|
||||
|
||||
const languageIdentifier = new LanguageIdentifier('bracketMode1', LanguageId.PlainText);
|
||||
let registration: IDisposable;
|
||||
|
||||
@@ -180,21 +180,21 @@ suite('TextModelWithTokens - bracket matching', () => {
|
||||
')]}{[(';
|
||||
let model = TextModel.createFromString(text, undefined, languageIdentifier);
|
||||
|
||||
isNotABracket(model, 1, 1);
|
||||
isNotABracket(model, 1, 2);
|
||||
isNotABracket(model, 1, 3);
|
||||
isBracket2(model, new Position(1, 4), [new Range(1, 4, 1, 5), new Range(2, 3, 2, 4)]);
|
||||
isBracket2(model, new Position(1, 5), [new Range(1, 5, 1, 6), new Range(2, 2, 2, 3)]);
|
||||
isBracket2(model, new Position(1, 6), [new Range(1, 6, 1, 7), new Range(2, 1, 2, 2)]);
|
||||
isBracket2(model, new Position(1, 7), [new Range(1, 6, 1, 7), new Range(2, 1, 2, 2)]);
|
||||
assertIsNotBracket(model, 1, 1);
|
||||
assertIsNotBracket(model, 1, 2);
|
||||
assertIsNotBracket(model, 1, 3);
|
||||
assertIsBracket(model, new Position(1, 4), [new Range(1, 4, 1, 5), new Range(2, 3, 2, 4)]);
|
||||
assertIsBracket(model, new Position(1, 5), [new Range(1, 5, 1, 6), new Range(2, 2, 2, 3)]);
|
||||
assertIsBracket(model, new Position(1, 6), [new Range(1, 6, 1, 7), new Range(2, 1, 2, 2)]);
|
||||
assertIsBracket(model, new Position(1, 7), [new Range(1, 6, 1, 7), new Range(2, 1, 2, 2)]);
|
||||
|
||||
isBracket2(model, new Position(2, 1), [new Range(2, 1, 2, 2), new Range(1, 6, 1, 7)]);
|
||||
isBracket2(model, new Position(2, 2), [new Range(2, 2, 2, 3), new Range(1, 5, 1, 6)]);
|
||||
isBracket2(model, new Position(2, 3), [new Range(2, 3, 2, 4), new Range(1, 4, 1, 5)]);
|
||||
isBracket2(model, new Position(2, 4), [new Range(2, 3, 2, 4), new Range(1, 4, 1, 5)]);
|
||||
isNotABracket(model, 2, 5);
|
||||
isNotABracket(model, 2, 6);
|
||||
isNotABracket(model, 2, 7);
|
||||
assertIsBracket(model, new Position(2, 1), [new Range(2, 1, 2, 2), new Range(1, 6, 1, 7)]);
|
||||
assertIsBracket(model, new Position(2, 2), [new Range(2, 2, 2, 3), new Range(1, 5, 1, 6)]);
|
||||
assertIsBracket(model, new Position(2, 3), [new Range(2, 3, 2, 4), new Range(1, 4, 1, 5)]);
|
||||
assertIsBracket(model, new Position(2, 4), [new Range(2, 3, 2, 4), new Range(1, 4, 1, 5)]);
|
||||
assertIsNotBracket(model, 2, 5);
|
||||
assertIsNotBracket(model, 2, 6);
|
||||
assertIsNotBracket(model, 2, 7);
|
||||
|
||||
model.dispose();
|
||||
});
|
||||
@@ -238,7 +238,7 @@ suite('TextModelWithTokens - bracket matching', () => {
|
||||
let isABracket: { [lineNumber: number]: { [col: number]: boolean; }; } = { 1: {}, 2: {}, 3: {}, 4: {}, 5: {} };
|
||||
for (let i = 0, len = brackets.length; i < len; i++) {
|
||||
let [testPos, b1, b2] = brackets[i];
|
||||
isBracket2(model, testPos, [b1, b2]);
|
||||
assertIsBracket(model, testPos, [b1, b2]);
|
||||
isABracket[testPos.lineNumber][testPos.column] = true;
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ suite('TextModelWithTokens - bracket matching', () => {
|
||||
let line = model.getLineContent(i);
|
||||
for (let j = 1, lenJ = line.length + 1; j <= lenJ; j++) {
|
||||
if (!isABracket[i].hasOwnProperty(<any>j)) {
|
||||
isNotABracket(model, i, j);
|
||||
assertIsNotBracket(model, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,6 +255,88 @@ suite('TextModelWithTokens - bracket matching', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('TextModelWithTokens', () => {
|
||||
|
||||
test('bracket matching 3', () => {
|
||||
|
||||
const languageIdentifier = new LanguageIdentifier('bracketMode2', LanguageId.PlainText);
|
||||
const registration = LanguageConfigurationRegistry.register(languageIdentifier, {
|
||||
brackets: [
|
||||
['if', 'end if'],
|
||||
['loop', 'end loop'],
|
||||
['begin', 'end']
|
||||
],
|
||||
});
|
||||
|
||||
const text = [
|
||||
'begin',
|
||||
' loop',
|
||||
' if then',
|
||||
' end if;',
|
||||
' end loop;',
|
||||
'end;',
|
||||
'',
|
||||
'begin',
|
||||
' loop',
|
||||
' if then',
|
||||
' end ifa;',
|
||||
' end loop;',
|
||||
'end;',
|
||||
].join('\n');
|
||||
|
||||
const model = TextModel.createFromString(text, undefined, languageIdentifier);
|
||||
|
||||
// <if> ... <end ifa> is not matched
|
||||
assertIsNotBracket(model, 10, 9);
|
||||
|
||||
// <if> ... <end if> is matched
|
||||
assertIsBracket(model, new Position(3, 9), [new Range(3, 9, 3, 11), new Range(4, 9, 4, 15)]);
|
||||
assertIsBracket(model, new Position(4, 9), [new Range(4, 9, 4, 15), new Range(3, 9, 3, 11)]);
|
||||
|
||||
// <loop> ... <end loop> is matched
|
||||
assertIsBracket(model, new Position(2, 5), [new Range(2, 5, 2, 9), new Range(5, 5, 5, 13)]);
|
||||
assertIsBracket(model, new Position(5, 5), [new Range(5, 5, 5, 13), new Range(2, 5, 2, 9)]);
|
||||
|
||||
// <begin> ... <end> is matched
|
||||
assertIsBracket(model, new Position(1, 1), [new Range(1, 1, 1, 6), new Range(6, 1, 6, 4)]);
|
||||
assertIsBracket(model, new Position(6, 1), [new Range(6, 1, 6, 4), new Range(1, 1, 1, 6)]);
|
||||
|
||||
model.dispose();
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
test('bracket matching 4', () => {
|
||||
|
||||
const languageIdentifier = new LanguageIdentifier('bracketMode2', LanguageId.PlainText);
|
||||
const registration = LanguageConfigurationRegistry.register(languageIdentifier, {
|
||||
brackets: [
|
||||
['recordbegin', 'endrecord'],
|
||||
['simplerecordbegin', 'endrecord'],
|
||||
],
|
||||
});
|
||||
|
||||
const text = [
|
||||
'recordbegin',
|
||||
' simplerecordbegin',
|
||||
' endrecord',
|
||||
'endrecord',
|
||||
].join('\n');
|
||||
|
||||
const model = TextModel.createFromString(text, undefined, languageIdentifier);
|
||||
|
||||
// <recordbegin> ... <endrecord> is matched
|
||||
assertIsBracket(model, new Position(1, 1), [new Range(1, 1, 1, 12), new Range(4, 1, 4, 10)]);
|
||||
assertIsBracket(model, new Position(4, 1), [new Range(4, 1, 4, 10), new Range(1, 1, 1, 12)]);
|
||||
|
||||
// <simplerecordbegin> ... <endrecord> is matched
|
||||
assertIsBracket(model, new Position(2, 3), [new Range(2, 3, 2, 20), new Range(3, 3, 3, 12)]);
|
||||
assertIsBracket(model, new Position(3, 3), [new Range(3, 3, 3, 12), new Range(2, 3, 2, 20)]);
|
||||
|
||||
model.dispose();
|
||||
registration.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
suite('TextModelWithTokens regression tests', () => {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { StandardTokenType } from 'vs/editor/common/modes';
|
||||
import { CharacterPairSupport } from 'vs/editor/common/modes/supports/characterPair';
|
||||
import { TokenText, createFakeScopedLineTokens } from 'vs/editor/test/common/modesTestUtils';
|
||||
import { StandardAutoClosingPairConditional } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
suite('CharacterPairSupport', () => {
|
||||
|
||||
@@ -53,13 +54,8 @@ suite('CharacterPairSupport', () => {
|
||||
assert.deepEqual(characaterPairSupport.getSurroundingPairs(), []);
|
||||
});
|
||||
|
||||
function findAutoClosingPair(characterPairSupport: CharacterPairSupport, character: string): StandardAutoClosingPairConditional | null {
|
||||
for (const autoClosingPair of characterPairSupport.getAutoClosingPairs()) {
|
||||
if (autoClosingPair.open === character) {
|
||||
return autoClosingPair;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
function findAutoClosingPair(characterPairSupport: CharacterPairSupport, character: string): StandardAutoClosingPairConditional | undefined {
|
||||
return find(characterPairSupport.getAutoClosingPairs(), autoClosingPair => autoClosingPair.open === character);
|
||||
}
|
||||
|
||||
function testShouldAutoClose(characterPairSupport: CharacterPairSupport, line: TokenText[], character: string, column: number): boolean {
|
||||
|
||||
@@ -9,71 +9,71 @@ import { BracketsUtils } from 'vs/editor/common/modes/supports/richEditBrackets'
|
||||
|
||||
suite('richEditBrackets', () => {
|
||||
|
||||
function findPrevBracketInToken(reversedBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range | null {
|
||||
return BracketsUtils.findPrevBracketInToken(reversedBracketRegex, 1, lineText, currentTokenStart, currentTokenEnd);
|
||||
function findPrevBracketInRange(reversedBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range | null {
|
||||
return BracketsUtils.findPrevBracketInRange(reversedBracketRegex, 1, lineText, currentTokenStart, currentTokenEnd);
|
||||
}
|
||||
|
||||
function findNextBracketInToken(forwardBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range | null {
|
||||
return BracketsUtils.findNextBracketInToken(forwardBracketRegex, 1, lineText, currentTokenStart, currentTokenEnd);
|
||||
function findNextBracketInRange(forwardBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range | null {
|
||||
return BracketsUtils.findNextBracketInRange(forwardBracketRegex, 1, lineText, currentTokenStart, currentTokenEnd);
|
||||
}
|
||||
|
||||
test('findPrevBracketInToken one char 1', () => {
|
||||
let result = findPrevBracketInToken(/(\{)|(\})/i, '{', 0, 1);
|
||||
let result = findPrevBracketInRange(/(\{)|(\})/i, '{', 0, 1);
|
||||
assert.equal(result!.startColumn, 1);
|
||||
assert.equal(result!.endColumn, 2);
|
||||
});
|
||||
|
||||
test('findPrevBracketInToken one char 2', () => {
|
||||
let result = findPrevBracketInToken(/(\{)|(\})/i, '{{', 0, 1);
|
||||
let result = findPrevBracketInRange(/(\{)|(\})/i, '{{', 0, 1);
|
||||
assert.equal(result!.startColumn, 1);
|
||||
assert.equal(result!.endColumn, 2);
|
||||
});
|
||||
|
||||
test('findPrevBracketInToken one char 3', () => {
|
||||
let result = findPrevBracketInToken(/(\{)|(\})/i, '{hello world!', 0, 13);
|
||||
let result = findPrevBracketInRange(/(\{)|(\})/i, '{hello world!', 0, 13);
|
||||
assert.equal(result!.startColumn, 1);
|
||||
assert.equal(result!.endColumn, 2);
|
||||
});
|
||||
|
||||
test('findPrevBracketInToken more chars 1', () => {
|
||||
let result = findPrevBracketInToken(/(olleh)/i, 'hello world!', 0, 12);
|
||||
let result = findPrevBracketInRange(/(olleh)/i, 'hello world!', 0, 12);
|
||||
assert.equal(result!.startColumn, 1);
|
||||
assert.equal(result!.endColumn, 6);
|
||||
});
|
||||
|
||||
test('findPrevBracketInToken more chars 2', () => {
|
||||
let result = findPrevBracketInToken(/(olleh)/i, 'hello world!', 0, 5);
|
||||
let result = findPrevBracketInRange(/(olleh)/i, 'hello world!', 0, 5);
|
||||
assert.equal(result!.startColumn, 1);
|
||||
assert.equal(result!.endColumn, 6);
|
||||
});
|
||||
|
||||
test('findPrevBracketInToken more chars 3', () => {
|
||||
let result = findPrevBracketInToken(/(olleh)/i, ' hello world!', 0, 6);
|
||||
let result = findPrevBracketInRange(/(olleh)/i, ' hello world!', 0, 6);
|
||||
assert.equal(result!.startColumn, 2);
|
||||
assert.equal(result!.endColumn, 7);
|
||||
});
|
||||
|
||||
test('findNextBracketInToken one char', () => {
|
||||
let result = findNextBracketInToken(/(\{)|(\})/i, '{', 0, 1);
|
||||
let result = findNextBracketInRange(/(\{)|(\})/i, '{', 0, 1);
|
||||
assert.equal(result!.startColumn, 1);
|
||||
assert.equal(result!.endColumn, 2);
|
||||
});
|
||||
|
||||
test('findNextBracketInToken more chars', () => {
|
||||
let result = findNextBracketInToken(/(world)/i, 'hello world!', 0, 12);
|
||||
let result = findNextBracketInRange(/(world)/i, 'hello world!', 0, 12);
|
||||
assert.equal(result!.startColumn, 7);
|
||||
assert.equal(result!.endColumn, 12);
|
||||
});
|
||||
|
||||
test('findNextBracketInToken with emoty result', () => {
|
||||
let result = findNextBracketInToken(/(\{)|(\})/i, '', 0, 0);
|
||||
let result = findNextBracketInRange(/(\{)|(\})/i, '', 0, 0);
|
||||
assert.equal(result, null);
|
||||
});
|
||||
|
||||
test('issue #3894: [Handlebars] Curly braces edit issues', () => {
|
||||
let result = findPrevBracketInToken(/(\-\-!<)|(>\-\-)|(\{\{)|(\}\})/i, '{{asd}}', 0, 2);
|
||||
let result = findPrevBracketInRange(/(\-\-!<)|(>\-\-)|(\{\{)|(\}\})/i, '{{asd}}', 0, 2);
|
||||
assert.equal(result!.startColumn, 1);
|
||||
assert.equal(result!.endColumn, 3);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -105,7 +105,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
const colorMap = [null!, '#000000', '#ffffff', '#ff0000', '#00ff00', '#0000ff'];
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 17, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 17, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
|
||||
@@ -118,7 +118,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 12, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 12, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
|
||||
@@ -131,7 +131,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 11, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 11, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
|
||||
@@ -143,7 +143,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 1, 11, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 1, 11, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">iao</span>',
|
||||
@@ -155,7 +155,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 4, 11, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 4, 11, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
@@ -166,7 +166,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 5, 11, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 5, 11, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
@@ -176,7 +176,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 5, 10, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 5, 10, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #00ff00;">hello</span>',
|
||||
@@ -185,7 +185,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 6, 9, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 6, 9, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #00ff00;">ell</span>',
|
||||
@@ -238,7 +238,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
const colorMap = [null!, '#000000', '#ffffff', '#ff0000', '#00ff00', '#0000ff'];
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 21, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 21, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
@@ -252,7 +252,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 17, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 17, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
@@ -266,7 +266,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 3, 4),
|
||||
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 3, 4, true),
|
||||
[
|
||||
'<div>',
|
||||
'<span style="color: #000000;"> </span>',
|
||||
|
||||
@@ -365,7 +365,7 @@ assertComputeEdits(file1, file2);
|
||||
}
|
||||
}
|
||||
|
||||
class TestTextResourcePropertiesService implements ITextResourcePropertiesService {
|
||||
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
@@ -375,11 +375,9 @@ class TestTextResourcePropertiesService implements ITextResourcePropertiesServic
|
||||
}
|
||||
|
||||
getEOL(resource: URI, language?: string): string {
|
||||
const filesConfiguration = this.configurationService.getValue<{ eol: string }>('files', { overrideIdentifier: language, resource });
|
||||
if (filesConfiguration && filesConfiguration.eol) {
|
||||
if (filesConfiguration.eol !== 'auto') {
|
||||
return filesConfiguration.eol;
|
||||
}
|
||||
const eol = this.configurationService.getValue<string>('files.eol', { overrideIdentifier: language, resource });
|
||||
if (eol && eol !== 'auto') {
|
||||
return eol;
|
||||
}
|
||||
return (platform.isLinux || platform.isMacintosh) ? '\n' : '\r\n';
|
||||
}
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Constants, MinimapCharRenderer } from 'vs/editor/common/view/minimapCharRenderer';
|
||||
|
||||
const enum InternalConstants {
|
||||
CA_CHANNELS_CNT = 2,
|
||||
}
|
||||
|
||||
export class MinimapCharRendererFactory {
|
||||
|
||||
public static create(source: Uint8ClampedArray): MinimapCharRenderer {
|
||||
const expectedLength = (Constants.SAMPLED_CHAR_HEIGHT * Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT * Constants.CHAR_COUNT);
|
||||
if (source.length !== expectedLength) {
|
||||
throw new Error('Unexpected source in MinimapCharRenderer');
|
||||
}
|
||||
|
||||
let x2CharData = this.toGrayscale(MinimapCharRendererFactory._downsample2x(source));
|
||||
let x1CharData = this.toGrayscale(MinimapCharRendererFactory._downsample1x(source));
|
||||
return new MinimapCharRenderer(x2CharData, x1CharData);
|
||||
}
|
||||
|
||||
private static toGrayscale(charData: Uint8ClampedArray): Uint8ClampedArray {
|
||||
let newLength = charData.length / 2;
|
||||
let result = new Uint8ClampedArray(newLength);
|
||||
let sourceOffset = 0;
|
||||
for (let i = 0; i < newLength; i++) {
|
||||
let color = charData[sourceOffset];
|
||||
let alpha = charData[sourceOffset + 1];
|
||||
let newColor = Math.round((color * alpha) / 255);
|
||||
result[i] = newColor;
|
||||
sourceOffset += 2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static _extractSampledChar(source: Uint8ClampedArray, charIndex: number, dest: Uint8ClampedArray) {
|
||||
let destOffset = 0;
|
||||
for (let i = 0; i < Constants.SAMPLED_CHAR_HEIGHT; i++) {
|
||||
let sourceOffset = (
|
||||
Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT * Constants.CHAR_COUNT * i
|
||||
+ Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT * charIndex
|
||||
);
|
||||
for (let j = 0; j < Constants.SAMPLED_CHAR_WIDTH; j++) {
|
||||
for (let c = 0; c < Constants.RGBA_CHANNELS_CNT; c++) {
|
||||
dest[destOffset] = source[sourceOffset];
|
||||
sourceOffset++;
|
||||
destOffset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static _downsample2xChar(source: Uint8ClampedArray, dest: Uint8ClampedArray): void {
|
||||
// chars are 2 x 4px (width x height)
|
||||
const resultLen = Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT;
|
||||
const result = new Uint16Array(resultLen);
|
||||
for (let i = 0; i < resultLen; i++) {
|
||||
result[i] = 0;
|
||||
}
|
||||
|
||||
let inputOffset = 0, globalOutputOffset = 0;
|
||||
for (let i = 0; i < Constants.SAMPLED_CHAR_HEIGHT; i++) {
|
||||
|
||||
let outputOffset = globalOutputOffset;
|
||||
|
||||
let color = 0;
|
||||
let alpha = 0;
|
||||
for (let j = 0; j < Constants.SAMPLED_HALF_CHAR_WIDTH; j++) {
|
||||
color += source[inputOffset]; // R
|
||||
alpha += source[inputOffset + 3]; // A
|
||||
inputOffset += Constants.RGBA_CHANNELS_CNT;
|
||||
}
|
||||
result[outputOffset] += color;
|
||||
result[outputOffset + 1] += alpha;
|
||||
outputOffset += InternalConstants.CA_CHANNELS_CNT;
|
||||
|
||||
color = 0;
|
||||
alpha = 0;
|
||||
for (let j = 0; j < Constants.SAMPLED_HALF_CHAR_WIDTH; j++) {
|
||||
color += source[inputOffset]; // R
|
||||
alpha += source[inputOffset + 3]; // A
|
||||
inputOffset += Constants.RGBA_CHANNELS_CNT;
|
||||
}
|
||||
result[outputOffset] += color;
|
||||
result[outputOffset + 1] += alpha;
|
||||
outputOffset += InternalConstants.CA_CHANNELS_CNT;
|
||||
|
||||
if (i === 2 || i === 5 || i === 8) {
|
||||
globalOutputOffset = outputOffset;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < resultLen; i++) {
|
||||
dest[i] = result[i] / 12; // 15 it should be
|
||||
}
|
||||
}
|
||||
|
||||
private static _downsample2x(data: Uint8ClampedArray): Uint8ClampedArray {
|
||||
const resultLen = Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT * Constants.CHAR_COUNT;
|
||||
const result = new Uint8ClampedArray(resultLen);
|
||||
|
||||
const sampledChar = new Uint8ClampedArray(Constants.SAMPLED_CHAR_HEIGHT * Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT);
|
||||
const downsampledChar = new Uint8ClampedArray(Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT);
|
||||
|
||||
for (let charIndex = 0; charIndex < Constants.CHAR_COUNT; charIndex++) {
|
||||
this._extractSampledChar(data, charIndex, sampledChar);
|
||||
this._downsample2xChar(sampledChar, downsampledChar);
|
||||
let resultOffset = (Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT * charIndex);
|
||||
for (let i = 0; i < downsampledChar.length; i++) {
|
||||
result[resultOffset + i] = downsampledChar[i];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static _downsample1xChar(source: Uint8ClampedArray, dest: Uint8ClampedArray): void {
|
||||
// chars are 1 x 2px (width x height)
|
||||
const resultLen = Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT;
|
||||
const result = new Uint16Array(resultLen);
|
||||
for (let i = 0; i < resultLen; i++) {
|
||||
result[i] = 0;
|
||||
}
|
||||
|
||||
let inputOffset = 0, globalOutputOffset = 0;
|
||||
for (let i = 0; i < Constants.SAMPLED_CHAR_HEIGHT; i++) {
|
||||
|
||||
let outputOffset = globalOutputOffset;
|
||||
|
||||
let color = 0;
|
||||
let alpha = 0;
|
||||
for (let j = 0; j < Constants.SAMPLED_CHAR_WIDTH; j++) {
|
||||
color += source[inputOffset]; // R
|
||||
alpha += source[inputOffset + 3]; // A
|
||||
inputOffset += Constants.RGBA_CHANNELS_CNT;
|
||||
}
|
||||
result[outputOffset] += color;
|
||||
result[outputOffset + 1] += alpha;
|
||||
outputOffset += InternalConstants.CA_CHANNELS_CNT;
|
||||
|
||||
if (i === 5) {
|
||||
globalOutputOffset = outputOffset;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < resultLen; i++) {
|
||||
dest[i] = result[i] / 50; // 60 it should be
|
||||
}
|
||||
}
|
||||
|
||||
private static _downsample1x(data: Uint8ClampedArray): Uint8ClampedArray {
|
||||
const resultLen = Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT * Constants.CHAR_COUNT;
|
||||
const result = new Uint8ClampedArray(resultLen);
|
||||
|
||||
const sampledChar = new Uint8ClampedArray(Constants.SAMPLED_CHAR_HEIGHT * Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT);
|
||||
const downsampledChar = new Uint8ClampedArray(Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT);
|
||||
|
||||
for (let charIndex = 0; charIndex < Constants.CHAR_COUNT; charIndex++) {
|
||||
this._extractSampledChar(data, charIndex, sampledChar);
|
||||
this._downsample1xChar(sampledChar, downsampledChar);
|
||||
let resultOffset = (Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT * charIndex);
|
||||
for (let i = 0; i < downsampledChar.length; i++) {
|
||||
result[resultOffset + i] = downsampledChar[i];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,8 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
|
||||
side: input.minimapSide,
|
||||
renderCharacters: input.minimapRenderCharacters,
|
||||
maxColumn: input.minimapMaxColumn,
|
||||
showSlider: 'mouseover'
|
||||
showSlider: 'mouseover',
|
||||
scale: 1,
|
||||
};
|
||||
options._write(EditorOption.minimap, minimapOptions);
|
||||
const scrollbarOptions: InternalEditorScrollbarOptions = {
|
||||
@@ -704,7 +705,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
|
||||
contentWidth: 901,
|
||||
contentHeight: 800,
|
||||
|
||||
renderMinimap: RenderMinimap.Small,
|
||||
renderMinimap: RenderMinimap.Text,
|
||||
minimapLeft: 911,
|
||||
minimapWidth: 89,
|
||||
viewportColumn: 89,
|
||||
@@ -762,7 +763,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
|
||||
contentWidth: 901,
|
||||
contentHeight: 800,
|
||||
|
||||
renderMinimap: RenderMinimap.Large,
|
||||
renderMinimap: RenderMinimap.Text,
|
||||
minimapLeft: 911,
|
||||
minimapWidth: 89,
|
||||
viewportColumn: 89,
|
||||
@@ -820,7 +821,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
|
||||
contentWidth: 943,
|
||||
contentHeight: 800,
|
||||
|
||||
renderMinimap: RenderMinimap.Large,
|
||||
renderMinimap: RenderMinimap.Text,
|
||||
minimapLeft: 953,
|
||||
minimapWidth: 47,
|
||||
viewportColumn: 94,
|
||||
@@ -878,7 +879,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
|
||||
contentWidth: 943,
|
||||
contentHeight: 800,
|
||||
|
||||
renderMinimap: RenderMinimap.Large,
|
||||
renderMinimap: RenderMinimap.Text,
|
||||
minimapLeft: 0,
|
||||
minimapWidth: 47,
|
||||
viewportColumn: 94,
|
||||
@@ -936,7 +937,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
|
||||
contentWidth: 1026,
|
||||
contentHeight: 422,
|
||||
|
||||
renderMinimap: RenderMinimap.Large,
|
||||
renderMinimap: RenderMinimap.Text,
|
||||
minimapLeft: 1104,
|
||||
minimapWidth: 83,
|
||||
viewportColumn: 83,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { toUint32Array } from 'vs/editor/common/core/uint';
|
||||
import { toUint32Array } from 'vs/base/common/uint';
|
||||
import { PrefixSumComputer, PrefixSumIndexOfResult } from 'vs/editor/common/viewModel/prefixSumComputer';
|
||||
|
||||
suite('Editor ViewModel - PrefixSumComputer', () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IViewLineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import { toUint32Array } from 'vs/editor/common/core/uint';
|
||||
import { toUint32Array } from 'vs/base/common/uint';
|
||||
import { EndOfLinePreference } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
|
||||
@@ -210,7 +210,7 @@ suite('ViewModel', () => {
|
||||
new Range(3, 2, 3, 2),
|
||||
],
|
||||
true,
|
||||
'ine2'
|
||||
['ine2', 'line3']
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user