@lvce-editor/editor-worker 19.43.0 → 19.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editorWorkerMain.js +488 -25
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1412,6 +1412,7 @@ const F12 = 68;
|
|
|
1412
1412
|
const Period = 87;
|
|
1413
1413
|
const Slash$1 = 88;
|
|
1414
1414
|
const BracketLeft = 90;
|
|
1415
|
+
const Backslash = 91;
|
|
1415
1416
|
const BracketRight = 92;
|
|
1416
1417
|
|
|
1417
1418
|
const CodeGenerator = 1;
|
|
@@ -4454,6 +4455,267 @@ const getMinimapLines = async (editor, syncIncremental) => {
|
|
|
4454
4455
|
return result.tokens.map((lineState, index) => getLine(lineState, result.embeddedResults, tokenMap, lines[index].length));
|
|
4455
4456
|
};
|
|
4456
4457
|
|
|
4458
|
+
const closingBrackets = {
|
|
4459
|
+
'(': ')',
|
|
4460
|
+
'[': ']',
|
|
4461
|
+
'{': '}'
|
|
4462
|
+
};
|
|
4463
|
+
const openingBrackets = {
|
|
4464
|
+
')': '(',
|
|
4465
|
+
']': '[',
|
|
4466
|
+
'}': '{'
|
|
4467
|
+
};
|
|
4468
|
+
const isOpeningBracket = character => character in closingBrackets;
|
|
4469
|
+
const isClosingBracket = character => character in openingBrackets;
|
|
4470
|
+
const isBefore$1 = (left, right) => left.rowIndex < right.rowIndex || left.rowIndex === right.rowIndex && left.columnIndex < right.columnIndex;
|
|
4471
|
+
const getCandidate = (lines, rowIndex, columnIndex) => {
|
|
4472
|
+
const line = lines.at(rowIndex);
|
|
4473
|
+
if (line === undefined) {
|
|
4474
|
+
return undefined;
|
|
4475
|
+
}
|
|
4476
|
+
const characterAtCursor = line[columnIndex];
|
|
4477
|
+
if (characterAtCursor && (isOpeningBracket(characterAtCursor) || isClosingBracket(characterAtCursor))) {
|
|
4478
|
+
return {
|
|
4479
|
+
character: characterAtCursor,
|
|
4480
|
+
position: {
|
|
4481
|
+
columnIndex,
|
|
4482
|
+
rowIndex
|
|
4483
|
+
}
|
|
4484
|
+
};
|
|
4485
|
+
}
|
|
4486
|
+
const characterBeforeCursor = line[columnIndex - 1];
|
|
4487
|
+
if (characterBeforeCursor && (isOpeningBracket(characterBeforeCursor) || isClosingBracket(characterBeforeCursor))) {
|
|
4488
|
+
return {
|
|
4489
|
+
character: characterBeforeCursor,
|
|
4490
|
+
position: {
|
|
4491
|
+
columnIndex: columnIndex - 1,
|
|
4492
|
+
rowIndex
|
|
4493
|
+
}
|
|
4494
|
+
};
|
|
4495
|
+
}
|
|
4496
|
+
return undefined;
|
|
4497
|
+
};
|
|
4498
|
+
const getCharacter = (lines, position) => lines[position.rowIndex][position.columnIndex];
|
|
4499
|
+
const findForward = (lines, source) => {
|
|
4500
|
+
const {
|
|
4501
|
+
columnIndex: sourceColumnIndex,
|
|
4502
|
+
rowIndex: sourceRowIndex
|
|
4503
|
+
} = source;
|
|
4504
|
+
const stack = [getCharacter(lines, source)];
|
|
4505
|
+
for (let rowIndex = sourceRowIndex; rowIndex < lines.length; rowIndex++) {
|
|
4506
|
+
const line = lines[rowIndex];
|
|
4507
|
+
const startColumnIndex = rowIndex === sourceRowIndex ? sourceColumnIndex + 1 : 0;
|
|
4508
|
+
for (let columnIndex = startColumnIndex; columnIndex < line.length; columnIndex++) {
|
|
4509
|
+
const character = line[columnIndex];
|
|
4510
|
+
if (isOpeningBracket(character)) {
|
|
4511
|
+
stack.push(character);
|
|
4512
|
+
} else if (isClosingBracket(character)) {
|
|
4513
|
+
const expectedOpeningBracket = openingBrackets[character];
|
|
4514
|
+
if (stack.at(-1) !== expectedOpeningBracket) {
|
|
4515
|
+
return undefined;
|
|
4516
|
+
}
|
|
4517
|
+
stack.pop();
|
|
4518
|
+
if (stack.length === 0) {
|
|
4519
|
+
return {
|
|
4520
|
+
columnIndex,
|
|
4521
|
+
rowIndex
|
|
4522
|
+
};
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
return undefined;
|
|
4528
|
+
};
|
|
4529
|
+
const findBackward = (lines, source) => {
|
|
4530
|
+
const {
|
|
4531
|
+
columnIndex: sourceColumnIndex,
|
|
4532
|
+
rowIndex: sourceRowIndex
|
|
4533
|
+
} = source;
|
|
4534
|
+
const stack = [getCharacter(lines, source)];
|
|
4535
|
+
for (let rowIndex = sourceRowIndex; rowIndex >= 0; rowIndex--) {
|
|
4536
|
+
const line = lines[rowIndex];
|
|
4537
|
+
let startColumnIndex = line.length - 1;
|
|
4538
|
+
if (rowIndex === sourceRowIndex) {
|
|
4539
|
+
startColumnIndex = sourceColumnIndex - 1;
|
|
4540
|
+
}
|
|
4541
|
+
for (let columnIndex = startColumnIndex; columnIndex >= 0; columnIndex--) {
|
|
4542
|
+
const character = line[columnIndex];
|
|
4543
|
+
if (isClosingBracket(character)) {
|
|
4544
|
+
stack.push(character);
|
|
4545
|
+
} else if (isOpeningBracket(character)) {
|
|
4546
|
+
const expectedClosingBracket = closingBrackets[character];
|
|
4547
|
+
if (stack.at(-1) !== expectedClosingBracket) {
|
|
4548
|
+
return undefined;
|
|
4549
|
+
}
|
|
4550
|
+
stack.pop();
|
|
4551
|
+
if (stack.length === 0) {
|
|
4552
|
+
return {
|
|
4553
|
+
columnIndex,
|
|
4554
|
+
rowIndex
|
|
4555
|
+
};
|
|
4556
|
+
}
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
return undefined;
|
|
4561
|
+
};
|
|
4562
|
+
const findMatchingBracket = (lines, rowIndex, columnIndex) => {
|
|
4563
|
+
const candidate = getCandidate(lines, rowIndex, columnIndex);
|
|
4564
|
+
if (!candidate) {
|
|
4565
|
+
return undefined;
|
|
4566
|
+
}
|
|
4567
|
+
const {
|
|
4568
|
+
character,
|
|
4569
|
+
position: source
|
|
4570
|
+
} = candidate;
|
|
4571
|
+
const match = isOpeningBracket(character) ? findForward(lines, source) : findBackward(lines, source);
|
|
4572
|
+
if (!match) {
|
|
4573
|
+
return undefined;
|
|
4574
|
+
}
|
|
4575
|
+
return {
|
|
4576
|
+
match,
|
|
4577
|
+
source,
|
|
4578
|
+
sourceIsBeforeCursor: source.columnIndex === columnIndex - 1 && source.rowIndex === rowIndex
|
|
4579
|
+
};
|
|
4580
|
+
};
|
|
4581
|
+
const findEnclosingBrackets = (lines, rowIndex, columnIndex) => {
|
|
4582
|
+
const cursor = {
|
|
4583
|
+
columnIndex,
|
|
4584
|
+
rowIndex
|
|
4585
|
+
};
|
|
4586
|
+
const stack = [];
|
|
4587
|
+
let enclosingPair;
|
|
4588
|
+
for (let currentRowIndex = 0; currentRowIndex < lines.length; currentRowIndex++) {
|
|
4589
|
+
const line = lines[currentRowIndex];
|
|
4590
|
+
for (let currentColumnIndex = 0; currentColumnIndex < line.length; currentColumnIndex++) {
|
|
4591
|
+
const character = line[currentColumnIndex];
|
|
4592
|
+
const position = {
|
|
4593
|
+
columnIndex: currentColumnIndex,
|
|
4594
|
+
rowIndex: currentRowIndex
|
|
4595
|
+
};
|
|
4596
|
+
if (isOpeningBracket(character)) {
|
|
4597
|
+
stack.push({
|
|
4598
|
+
character,
|
|
4599
|
+
position
|
|
4600
|
+
});
|
|
4601
|
+
} else if (isClosingBracket(character)) {
|
|
4602
|
+
const openingBracket = stack.at(-1);
|
|
4603
|
+
if (!openingBracket || openingBracket.character !== openingBrackets[character]) {
|
|
4604
|
+
stack.length = 0;
|
|
4605
|
+
} else {
|
|
4606
|
+
stack.pop();
|
|
4607
|
+
if (!enclosingPair && isBefore$1(openingBracket.position, cursor) && isBefore$1(cursor, position)) {
|
|
4608
|
+
enclosingPair = {
|
|
4609
|
+
match: position,
|
|
4610
|
+
source: openingBracket.position,
|
|
4611
|
+
sourceIsBeforeCursor: false
|
|
4612
|
+
};
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
}
|
|
4616
|
+
}
|
|
4617
|
+
}
|
|
4618
|
+
return enclosingPair;
|
|
4619
|
+
};
|
|
4620
|
+
const findNextBracket = (lines, rowIndex, columnIndex) => {
|
|
4621
|
+
for (let currentRowIndex = rowIndex; currentRowIndex < lines.length; currentRowIndex++) {
|
|
4622
|
+
const line = lines[currentRowIndex];
|
|
4623
|
+
const startColumnIndex = currentRowIndex === rowIndex ? columnIndex : 0;
|
|
4624
|
+
for (let currentColumnIndex = startColumnIndex; currentColumnIndex < line.length; currentColumnIndex++) {
|
|
4625
|
+
const character = line[currentColumnIndex];
|
|
4626
|
+
if (isOpeningBracket(character) || isClosingBracket(character)) {
|
|
4627
|
+
return {
|
|
4628
|
+
columnIndex: currentColumnIndex,
|
|
4629
|
+
rowIndex: currentRowIndex
|
|
4630
|
+
};
|
|
4631
|
+
}
|
|
4632
|
+
}
|
|
4633
|
+
}
|
|
4634
|
+
return undefined;
|
|
4635
|
+
};
|
|
4636
|
+
const findBracketPair = (lines, rowIndex, columnIndex) => {
|
|
4637
|
+
const directPair = findMatchingBracket(lines, rowIndex, columnIndex);
|
|
4638
|
+
if (directPair) {
|
|
4639
|
+
return directPair;
|
|
4640
|
+
}
|
|
4641
|
+
const enclosingPair = findEnclosingBrackets(lines, rowIndex, columnIndex);
|
|
4642
|
+
if (enclosingPair) {
|
|
4643
|
+
return enclosingPair;
|
|
4644
|
+
}
|
|
4645
|
+
const nextBracket = findNextBracket(lines, rowIndex, columnIndex);
|
|
4646
|
+
if (!nextBracket) {
|
|
4647
|
+
return undefined;
|
|
4648
|
+
}
|
|
4649
|
+
return findMatchingBracket(lines, nextBracket.rowIndex, nextBracket.columnIndex);
|
|
4650
|
+
};
|
|
4651
|
+
|
|
4652
|
+
const getPositionKey = position => `${position.rowIndex}:${position.columnIndex}`;
|
|
4653
|
+
const getInfo = async (editor, position, visibleLineIndices, startVisualRow) => {
|
|
4654
|
+
if (!visibleLineIndices.includes(position.rowIndex)) {
|
|
4655
|
+
return undefined;
|
|
4656
|
+
}
|
|
4657
|
+
const {
|
|
4658
|
+
charWidth,
|
|
4659
|
+
differences,
|
|
4660
|
+
foldingRanges,
|
|
4661
|
+
fontFamily,
|
|
4662
|
+
fontSize,
|
|
4663
|
+
fontWeight,
|
|
4664
|
+
isMonospaceFont,
|
|
4665
|
+
letterSpacing,
|
|
4666
|
+
lines,
|
|
4667
|
+
rowHeight,
|
|
4668
|
+
tabSize,
|
|
4669
|
+
width
|
|
4670
|
+
} = editor;
|
|
4671
|
+
const visualRow = getVisualRowForDocumentRow(position.rowIndex, foldingRanges);
|
|
4672
|
+
const relativeRow = visualRow - startVisualRow;
|
|
4673
|
+
const difference = differences[relativeRow] ?? 0;
|
|
4674
|
+
const line = lines[position.rowIndex];
|
|
4675
|
+
const x = await getX(line, position.columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth, difference);
|
|
4676
|
+
const endX = await getX(line, position.columnIndex + 1, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth, difference);
|
|
4677
|
+
return {
|
|
4678
|
+
height: rowHeight,
|
|
4679
|
+
width: Math.max(1, endX - x),
|
|
4680
|
+
x,
|
|
4681
|
+
y: relativeRow * rowHeight
|
|
4682
|
+
};
|
|
4683
|
+
};
|
|
4684
|
+
const getVisibleBracketMatches = async editor => {
|
|
4685
|
+
const {
|
|
4686
|
+
deltaY,
|
|
4687
|
+
foldingRanges,
|
|
4688
|
+
itemHeight,
|
|
4689
|
+
lines,
|
|
4690
|
+
maxLineY,
|
|
4691
|
+
minLineY,
|
|
4692
|
+
selections,
|
|
4693
|
+
visibleLineIndices
|
|
4694
|
+
} = editor;
|
|
4695
|
+
const actualVisibleLineIndices = visibleLineIndices || Array.from({
|
|
4696
|
+
length: maxLineY - minLineY
|
|
4697
|
+
}, (_, index) => minLineY + index);
|
|
4698
|
+
const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : getVisualRowForDocumentRow(minLineY, foldingRanges);
|
|
4699
|
+
const positions = new Map();
|
|
4700
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
4701
|
+
const startRowIndex = selections[i];
|
|
4702
|
+
const startColumnIndex = selections[i + 1];
|
|
4703
|
+
const endRowIndex = selections[i + 2];
|
|
4704
|
+
const endColumnIndex = selections[i + 3];
|
|
4705
|
+
if (startRowIndex !== endRowIndex || startColumnIndex !== endColumnIndex) {
|
|
4706
|
+
continue;
|
|
4707
|
+
}
|
|
4708
|
+
const pair = findMatchingBracket(lines, endRowIndex, endColumnIndex);
|
|
4709
|
+
if (!pair) {
|
|
4710
|
+
continue;
|
|
4711
|
+
}
|
|
4712
|
+
positions.set(getPositionKey(pair.source), pair.source);
|
|
4713
|
+
positions.set(getPositionKey(pair.match), pair.match);
|
|
4714
|
+
}
|
|
4715
|
+
const infos = await Promise.all(Array.from(positions.values(), position => getInfo(editor, position, actualVisibleLineIndices, startVisualRow)));
|
|
4716
|
+
return infos.filter(info => info !== undefined);
|
|
4717
|
+
};
|
|
4718
|
+
|
|
4457
4719
|
const getDiagnosticType = diagnostic => {
|
|
4458
4720
|
return diagnostic.type;
|
|
4459
4721
|
};
|
|
@@ -4506,6 +4768,12 @@ const shouldUpdateDiagnosticData = (oldState, newState) => {
|
|
|
4506
4768
|
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
4507
4769
|
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
4508
4770
|
};
|
|
4771
|
+
const shouldUpdateBracketMatchData = (oldState, newState) => {
|
|
4772
|
+
if (!('bracketMatchInfos' in newState)) {
|
|
4773
|
+
return false;
|
|
4774
|
+
}
|
|
4775
|
+
return oldState.selections !== newState.selections || oldState.lines !== newState.lines || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
4776
|
+
};
|
|
4509
4777
|
const shouldUpdateLightBulb = (oldState, newState) => oldState.diagnostics !== newState.diagnostics || oldState.languageId !== newState.languageId || oldState.selections !== newState.selections || oldState.uri !== newState.uri;
|
|
4510
4778
|
const shouldUpdateVisibleTextData = (oldState, newState) => {
|
|
4511
4779
|
if (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences) {
|
|
@@ -4546,6 +4814,12 @@ const updateDerivedState = async (oldState, newState) => {
|
|
|
4546
4814
|
minimapRevision: finalState.minimapRevision + 1
|
|
4547
4815
|
};
|
|
4548
4816
|
}
|
|
4817
|
+
if (shouldUpdateBracketMatchData(oldState, finalState)) {
|
|
4818
|
+
finalState = {
|
|
4819
|
+
...finalState,
|
|
4820
|
+
bracketMatchInfos: await getVisibleBracketMatches(finalState)
|
|
4821
|
+
};
|
|
4822
|
+
}
|
|
4549
4823
|
if (shouldUpdateDiagnosticData(oldState, nextState)) {
|
|
4550
4824
|
const visualDecorations = await getVisibleDiagnostics(finalState, finalState.diagnostics ?? []);
|
|
4551
4825
|
finalState = {
|
|
@@ -4673,6 +4947,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
4673
4947
|
const editor = {
|
|
4674
4948
|
additionalFocus: 0,
|
|
4675
4949
|
assetDir,
|
|
4950
|
+
bracketMatchInfos: [],
|
|
4676
4951
|
breadcrumbsEnabled: false,
|
|
4677
4952
|
breakPoints: [],
|
|
4678
4953
|
charWidth: 0,
|
|
@@ -4691,6 +4966,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
4691
4966
|
differences: [],
|
|
4692
4967
|
documentSymbols: [],
|
|
4693
4968
|
embeds: [],
|
|
4969
|
+
endOfLine: 'lf',
|
|
4694
4970
|
endOfLineDecorations: [],
|
|
4695
4971
|
finalDeltaY: 0,
|
|
4696
4972
|
finalY: 0,
|
|
@@ -4711,6 +4987,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
4711
4987
|
id,
|
|
4712
4988
|
incrementalEdits: emptyIncrementalEdits,
|
|
4713
4989
|
initial: true,
|
|
4990
|
+
insertSpaces: true,
|
|
4714
4991
|
invalidStartIndex: 0,
|
|
4715
4992
|
isAutoClosingBracketsEnabled: false,
|
|
4716
4993
|
isAutoClosingQuotesEnabled: false,
|
|
@@ -4774,6 +5051,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
4774
5051
|
};
|
|
4775
5052
|
|
|
4776
5053
|
const emptyEditor = {
|
|
5054
|
+
bracketMatchInfos: [],
|
|
4777
5055
|
breadcrumbsEnabled: false,
|
|
4778
5056
|
breakPoints: [],
|
|
4779
5057
|
cursorInfos: [],
|
|
@@ -4785,6 +5063,7 @@ const emptyEditor = {
|
|
|
4785
5063
|
differences: [],
|
|
4786
5064
|
documentSymbols: [],
|
|
4787
5065
|
embeds: [],
|
|
5066
|
+
endOfLine: 'lf',
|
|
4788
5067
|
endOfLineDecorations: [],
|
|
4789
5068
|
focused: false,
|
|
4790
5069
|
foldingRanges: [],
|
|
@@ -4792,6 +5071,7 @@ const emptyEditor = {
|
|
|
4792
5071
|
height: 0,
|
|
4793
5072
|
highlightedLine: -1,
|
|
4794
5073
|
incrementalEdits: emptyIncrementalEdits,
|
|
5074
|
+
insertSpaces: true,
|
|
4795
5075
|
isSelecting: false,
|
|
4796
5076
|
languageId: '',
|
|
4797
5077
|
// TODO use numeric language id?
|
|
@@ -4828,6 +5108,13 @@ const emptyEditor = {
|
|
|
4828
5108
|
y: 0
|
|
4829
5109
|
};
|
|
4830
5110
|
|
|
5111
|
+
const Lf = 'lf';
|
|
5112
|
+
const Crlf = 'crlf';
|
|
5113
|
+
|
|
5114
|
+
const getEndOfLine = content => {
|
|
5115
|
+
return content.includes('\r\n') ? Crlf : Lf;
|
|
5116
|
+
};
|
|
5117
|
+
|
|
4831
5118
|
const getFileExtensionIndex = file => {
|
|
4832
5119
|
string(file);
|
|
4833
5120
|
return file.lastIndexOf(Dot);
|
|
@@ -4895,6 +5182,13 @@ const measureCharacterWidth = async (fontWeight, fontSize, fontFamily, letterSpa
|
|
|
4895
5182
|
return await measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
|
|
4896
5183
|
};
|
|
4897
5184
|
|
|
5185
|
+
const normalizeLineEndings = content => {
|
|
5186
|
+
return content.replaceAll('\r\n', '\n').replaceAll('\r', '\n');
|
|
5187
|
+
};
|
|
5188
|
+
const applyLineEndings = (content, endOfLine) => {
|
|
5189
|
+
return endOfLine === Crlf ? normalizeLineEndings(content).replaceAll('\n', '\r\n') : normalizeLineEndings(content);
|
|
5190
|
+
};
|
|
5191
|
+
|
|
4898
5192
|
const get$3 = async key => {
|
|
4899
5193
|
const value = await getPreference(key);
|
|
4900
5194
|
return value;
|
|
@@ -4942,6 +5236,7 @@ const createEditor = async ({
|
|
|
4942
5236
|
const computedlanguageId = getLanguageId$1(uri, languages);
|
|
4943
5237
|
const editor = {
|
|
4944
5238
|
assetDir,
|
|
5239
|
+
bracketMatchInfos: [],
|
|
4945
5240
|
breakPoints: [],
|
|
4946
5241
|
charWidth,
|
|
4947
5242
|
columnWidth: 0,
|
|
@@ -4956,6 +5251,7 @@ const createEditor = async ({
|
|
|
4956
5251
|
diagnostics: [],
|
|
4957
5252
|
diagnosticsEnabled,
|
|
4958
5253
|
differences: [],
|
|
5254
|
+
endOfLine: getEndOfLine(content),
|
|
4959
5255
|
endOfLineDecorations: [],
|
|
4960
5256
|
finalDeltaY: 0,
|
|
4961
5257
|
finalY: 0,
|
|
@@ -4972,6 +5268,7 @@ const createEditor = async ({
|
|
|
4972
5268
|
height,
|
|
4973
5269
|
id,
|
|
4974
5270
|
incrementalEdits: emptyIncrementalEdits,
|
|
5271
|
+
insertSpaces: true,
|
|
4975
5272
|
invalidStartIndex: 0,
|
|
4976
5273
|
isAutoClosingBracketsEnabled,
|
|
4977
5274
|
isAutoClosingQuotesEnabled,
|
|
@@ -5027,7 +5324,7 @@ const createEditor = async ({
|
|
|
5027
5324
|
|
|
5028
5325
|
// TODO avoid creating intermediate editors here
|
|
5029
5326
|
const newEditor1 = setBounds(editor, x, y, width, height, 9);
|
|
5030
|
-
const newEditor2 = setText$1(newEditor1, content);
|
|
5327
|
+
const newEditor2 = setText$1(newEditor1, normalizeLineEndings(content));
|
|
5031
5328
|
let newEditor3;
|
|
5032
5329
|
if (lineToReveal && columnToReveal) {
|
|
5033
5330
|
const delta = lineToReveal * rowHeight;
|
|
@@ -5095,12 +5392,14 @@ const createStandaloneEditor = async ({
|
|
|
5095
5392
|
charWidth,
|
|
5096
5393
|
columnWidth: charWidth,
|
|
5097
5394
|
completionsOnType: false,
|
|
5395
|
+
endOfLine: getEndOfLine(content),
|
|
5098
5396
|
focus: FocusEditorText$1,
|
|
5099
5397
|
focused: true,
|
|
5100
5398
|
fontFamily,
|
|
5101
5399
|
fontSize,
|
|
5102
5400
|
fontWeight,
|
|
5103
5401
|
initial: false,
|
|
5402
|
+
insertSpaces: true,
|
|
5104
5403
|
isMonospaceFont: true,
|
|
5105
5404
|
itemHeight: rowHeight,
|
|
5106
5405
|
languageId,
|
|
@@ -5112,7 +5411,7 @@ const createStandaloneEditor = async ({
|
|
|
5112
5411
|
tokenizerId
|
|
5113
5412
|
};
|
|
5114
5413
|
const boundedEditor = setBounds(configuredEditor, x, y, width, height, charWidth);
|
|
5115
|
-
const editorWithText = setText$1(boundedEditor, content);
|
|
5414
|
+
const editorWithText = setText$1(boundedEditor, normalizeLineEndings(content));
|
|
5116
5415
|
const {
|
|
5117
5416
|
differences,
|
|
5118
5417
|
textInfos
|
|
@@ -5156,7 +5455,7 @@ const isEqual$3 = (oldState, newState) => {
|
|
|
5156
5455
|
};
|
|
5157
5456
|
|
|
5158
5457
|
const isEqual$2 = (oldState, newState) => {
|
|
5159
|
-
return oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
|
|
5458
|
+
return oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
|
|
5160
5459
|
};
|
|
5161
5460
|
|
|
5162
5461
|
const isEqual$1 = (oldState, newState) => {
|
|
@@ -5246,6 +5545,8 @@ const getEditorStatus = editor => {
|
|
|
5246
5545
|
return {
|
|
5247
5546
|
column: columnIndex + 1,
|
|
5248
5547
|
encoding: 'utf8',
|
|
5548
|
+
endOfLine: editor.endOfLine,
|
|
5549
|
+
insertSpaces: editor.insertSpaces,
|
|
5249
5550
|
languageId: editor.languageId,
|
|
5250
5551
|
line: rowIndex + 1,
|
|
5251
5552
|
tabSize: editor.tabSize
|
|
@@ -5253,7 +5554,7 @@ const getEditorStatus = editor => {
|
|
|
5253
5554
|
};
|
|
5254
5555
|
|
|
5255
5556
|
const equals = (oldStatus, newStatus) => {
|
|
5256
|
-
return oldStatus.column === newStatus.column && oldStatus.encoding === newStatus.encoding && oldStatus.languageId === newStatus.languageId && oldStatus.line === newStatus.line && oldStatus.tabSize === newStatus.tabSize;
|
|
5557
|
+
return oldStatus.column === newStatus.column && oldStatus.endOfLine === newStatus.endOfLine && oldStatus.encoding === newStatus.encoding && oldStatus.insertSpaces === newStatus.insertSpaces && oldStatus.languageId === newStatus.languageId && oldStatus.line === newStatus.line && oldStatus.tabSize === newStatus.tabSize;
|
|
5257
5558
|
};
|
|
5258
5559
|
const notifyEditorStatusChange = async (oldEditor, newEditor) => {
|
|
5259
5560
|
if (newEditor.initial || !newEditor.focused) {
|
|
@@ -5894,7 +6195,7 @@ const save = async editor => {
|
|
|
5894
6195
|
uri
|
|
5895
6196
|
} = editor;
|
|
5896
6197
|
const newEditor = await getNewEditor$1(editor);
|
|
5897
|
-
const content = getText$1(newEditor);
|
|
6198
|
+
const content = applyLineEndings(getText$1(newEditor), newEditor.endOfLine);
|
|
5898
6199
|
if (isUntitledFile(uri)) {
|
|
5899
6200
|
const pickedFilePath = await saveUntitledFile(uri, content, platform);
|
|
5900
6201
|
if (pickedFilePath) {
|
|
@@ -7635,6 +7936,33 @@ const getWordBefore = (editor, rowIndex, columnIndex) => {
|
|
|
7635
7936
|
return getWordBefore$1(line, columnIndex);
|
|
7636
7937
|
};
|
|
7637
7938
|
|
|
7939
|
+
const goToBracket$1 = editor => {
|
|
7940
|
+
const {
|
|
7941
|
+
lines,
|
|
7942
|
+
selections
|
|
7943
|
+
} = editor;
|
|
7944
|
+
const newSelections = new Uint32Array(selections);
|
|
7945
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
7946
|
+
const [startRowIndex, startColumnIndex] = getSelectionPairs(selections, i);
|
|
7947
|
+
const directPair = findMatchingBracket(lines, startRowIndex, startColumnIndex);
|
|
7948
|
+
let target = directPair?.match;
|
|
7949
|
+
if (!target) {
|
|
7950
|
+
target = findEnclosingBrackets(lines, startRowIndex, startColumnIndex)?.match;
|
|
7951
|
+
}
|
|
7952
|
+
if (!target) {
|
|
7953
|
+
target = findNextBracket(lines, startRowIndex, startColumnIndex);
|
|
7954
|
+
}
|
|
7955
|
+
if (!target) {
|
|
7956
|
+
continue;
|
|
7957
|
+
}
|
|
7958
|
+
newSelections[i] = target.rowIndex;
|
|
7959
|
+
newSelections[i + 1] = target.columnIndex;
|
|
7960
|
+
newSelections[i + 2] = target.rowIndex;
|
|
7961
|
+
newSelections[i + 3] = target.columnIndex;
|
|
7962
|
+
}
|
|
7963
|
+
return scheduleSelections(editor, newSelections);
|
|
7964
|
+
};
|
|
7965
|
+
|
|
7638
7966
|
// @ts-ignore
|
|
7639
7967
|
const getDefinition = async (editor, offset) => {
|
|
7640
7968
|
return execute({
|
|
@@ -7687,6 +8015,7 @@ const FindAllReferences = 'Find All References';
|
|
|
7687
8015
|
const Fold = 'Editor: Fold';
|
|
7688
8016
|
const FormatDocument = 'Format Document';
|
|
7689
8017
|
const GoToDefinition = 'Go to Definition';
|
|
8018
|
+
const GoToBracket = 'Go to Bracket';
|
|
7690
8019
|
const GoToTypeDefinition = 'Go to Type Definition';
|
|
7691
8020
|
const MoveLineDown = 'Move Line Down';
|
|
7692
8021
|
const MoveLineUp = 'Move Line Up';
|
|
@@ -7696,6 +8025,7 @@ const NoTypeDefinitionFound = 'No type definition found';
|
|
|
7696
8025
|
const NoTypeDefinitionFoundFor = "No type definition found for '{PH1}'";
|
|
7697
8026
|
const Paste = 'Paste';
|
|
7698
8027
|
const Redo = 'Redo';
|
|
8028
|
+
const SelectToBracket = 'Select to Bracket';
|
|
7699
8029
|
const SourceAction = 'Source Action';
|
|
7700
8030
|
const ToggleBlockComment = 'Toggle Block Comment';
|
|
7701
8031
|
const ToggleBreakpoint = 'Toggle Breakpoint';
|
|
@@ -7705,6 +8035,9 @@ const Unfold = 'Editor: Unfold';
|
|
|
7705
8035
|
const goToDefinition$1 = () => {
|
|
7706
8036
|
return i18nString(GoToDefinition);
|
|
7707
8037
|
};
|
|
8038
|
+
const goToBracket = () => {
|
|
8039
|
+
return i18nString(GoToBracket);
|
|
8040
|
+
};
|
|
7708
8041
|
const noDefinitionFound = () => {
|
|
7709
8042
|
return i18nString(NoDefinitionFound);
|
|
7710
8043
|
};
|
|
@@ -7772,6 +8105,9 @@ const toggleBlockComment$1 = () => {
|
|
|
7772
8105
|
const toggleBreakpoint$1 = () => {
|
|
7773
8106
|
return i18nString(ToggleBreakpoint);
|
|
7774
8107
|
};
|
|
8108
|
+
const selectToBracket$1 = () => {
|
|
8109
|
+
return i18nString(SelectToBracket);
|
|
8110
|
+
};
|
|
7775
8111
|
const moveLineUp$1 = () => {
|
|
7776
8112
|
return i18nString(MoveLineUp);
|
|
7777
8113
|
};
|
|
@@ -9339,7 +9675,14 @@ const indentLess = editor => {
|
|
|
9339
9675
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9340
9676
|
};
|
|
9341
9677
|
|
|
9342
|
-
const
|
|
9678
|
+
const getIndentString = ({
|
|
9679
|
+
insertSpaces,
|
|
9680
|
+
tabSize
|
|
9681
|
+
}) => {
|
|
9682
|
+
return insertSpaces ?? true ? ' '.repeat(tabSize || 2) : '\t';
|
|
9683
|
+
};
|
|
9684
|
+
|
|
9685
|
+
const getChanges$1 = (selections, indent) => {
|
|
9343
9686
|
const rowsToIndent = [];
|
|
9344
9687
|
for (let i = 0; i < selections.length; i += 4) {
|
|
9345
9688
|
const selectionStartRow = selections[i];
|
|
@@ -9354,7 +9697,7 @@ const getChanges$1 = selections => {
|
|
|
9354
9697
|
columnIndex: 0,
|
|
9355
9698
|
rowIndex: rowToIndent
|
|
9356
9699
|
},
|
|
9357
|
-
inserted: [
|
|
9700
|
+
inserted: [indent],
|
|
9358
9701
|
origin: IndentMore,
|
|
9359
9702
|
start: {
|
|
9360
9703
|
columnIndex: 0,
|
|
@@ -9367,7 +9710,7 @@ const indentMore = editor => {
|
|
|
9367
9710
|
const {
|
|
9368
9711
|
selections
|
|
9369
9712
|
} = editor;
|
|
9370
|
-
const changes = getChanges$1(selections);
|
|
9713
|
+
const changes = getChanges$1(selections, getIndentString(editor));
|
|
9371
9714
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9372
9715
|
};
|
|
9373
9716
|
|
|
@@ -9392,7 +9735,7 @@ const shouldIncreaseIndent = (before, increaseIndentRegex) => {
|
|
|
9392
9735
|
}
|
|
9393
9736
|
return increaseIndentRegex.test(before);
|
|
9394
9737
|
};
|
|
9395
|
-
const getChanges = (lines, selections, languageConfiguration) => {
|
|
9738
|
+
const getChanges = (lines, selections, languageConfiguration, indentUnit) => {
|
|
9396
9739
|
const changes = [];
|
|
9397
9740
|
const selectionChanges = [];
|
|
9398
9741
|
const increaseIndentRegex = getIncreaseIndentRegex(languageConfiguration);
|
|
@@ -9420,11 +9763,11 @@ const getChanges = (lines, selections, languageConfiguration) => {
|
|
|
9420
9763
|
lines
|
|
9421
9764
|
}, range),
|
|
9422
9765
|
end: end,
|
|
9423
|
-
inserted: ['', indent +
|
|
9766
|
+
inserted: ['', indent + indentUnit, indent],
|
|
9424
9767
|
origin: InsertLineBreak,
|
|
9425
9768
|
start: start
|
|
9426
9769
|
});
|
|
9427
|
-
selectionChanges.push(selectionStartRow + 1, indent.length +
|
|
9770
|
+
selectionChanges.push(selectionStartRow + 1, indent.length + indentUnit.length, selectionStartRow + 1, indent.length + indentUnit.length);
|
|
9428
9771
|
} else {
|
|
9429
9772
|
changes.push({
|
|
9430
9773
|
deleted: getSelectionText({
|
|
@@ -9464,7 +9807,7 @@ const insertLineBreak = async editor => {
|
|
|
9464
9807
|
const {
|
|
9465
9808
|
changes,
|
|
9466
9809
|
selectionChanges
|
|
9467
|
-
} = getChanges(lines, selections, languageConfiguration);
|
|
9810
|
+
} = getChanges(lines, selections, languageConfiguration, getIndentString(editor));
|
|
9468
9811
|
return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
9469
9812
|
};
|
|
9470
9813
|
|
|
@@ -10703,6 +11046,36 @@ const selectPreviousOccurrence = editor => {
|
|
|
10703
11046
|
return editor;
|
|
10704
11047
|
};
|
|
10705
11048
|
|
|
11049
|
+
const isBefore = (left, right) => left.rowIndex < right.rowIndex || left.rowIndex === right.rowIndex && left.columnIndex < right.columnIndex;
|
|
11050
|
+
const selectToBracket = editor => {
|
|
11051
|
+
const {
|
|
11052
|
+
lines,
|
|
11053
|
+
selections
|
|
11054
|
+
} = editor;
|
|
11055
|
+
const newSelections = new Uint32Array(selections);
|
|
11056
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
11057
|
+
const [rowIndex, columnIndex] = getSelectionPairs(selections, i);
|
|
11058
|
+
const pair = findBracketPair(lines, rowIndex, columnIndex);
|
|
11059
|
+
if (!pair) {
|
|
11060
|
+
continue;
|
|
11061
|
+
}
|
|
11062
|
+
const start = isBefore(pair.source, pair.match) ? pair.source : pair.match;
|
|
11063
|
+
const end = start === pair.source ? pair.match : pair.source;
|
|
11064
|
+
if (pair.source === end) {
|
|
11065
|
+
newSelections[i] = end.rowIndex;
|
|
11066
|
+
newSelections[i + 1] = end.columnIndex + 1;
|
|
11067
|
+
newSelections[i + 2] = start.rowIndex;
|
|
11068
|
+
newSelections[i + 3] = start.columnIndex;
|
|
11069
|
+
} else {
|
|
11070
|
+
newSelections[i] = start.rowIndex;
|
|
11071
|
+
newSelections[i + 1] = start.columnIndex;
|
|
11072
|
+
newSelections[i + 2] = end.rowIndex;
|
|
11073
|
+
newSelections[i + 3] = end.columnIndex + 1;
|
|
11074
|
+
}
|
|
11075
|
+
}
|
|
11076
|
+
return scheduleSelections(editor, newSelections);
|
|
11077
|
+
};
|
|
11078
|
+
|
|
10706
11079
|
// @ts-ignore
|
|
10707
11080
|
|
|
10708
11081
|
// @ts-ignore
|
|
@@ -10747,6 +11120,36 @@ const setDecorations = (editor, decorations, diagnostics) => {
|
|
|
10747
11120
|
};
|
|
10748
11121
|
};
|
|
10749
11122
|
|
|
11123
|
+
const setEndOfLine = async (editor, endOfLine) => {
|
|
11124
|
+
if (endOfLine !== Lf && endOfLine !== Crlf) {
|
|
11125
|
+
throw new TypeError(`Unsupported end of line sequence: ${endOfLine}`);
|
|
11126
|
+
}
|
|
11127
|
+
if (editor.endOfLine === endOfLine) {
|
|
11128
|
+
return editor;
|
|
11129
|
+
}
|
|
11130
|
+
if (!editor.modified) {
|
|
11131
|
+
await notifyTabModifiedStatusChange(editor.uri, true);
|
|
11132
|
+
}
|
|
11133
|
+
return {
|
|
11134
|
+
...editor,
|
|
11135
|
+
endOfLine,
|
|
11136
|
+
focused: true,
|
|
11137
|
+
lines: [...editor.lines],
|
|
11138
|
+
modified: true
|
|
11139
|
+
};
|
|
11140
|
+
};
|
|
11141
|
+
|
|
11142
|
+
const setIndentation = (editor, insertSpaces) => {
|
|
11143
|
+
if (editor.insertSpaces === insertSpaces) {
|
|
11144
|
+
return editor;
|
|
11145
|
+
}
|
|
11146
|
+
return {
|
|
11147
|
+
...editor,
|
|
11148
|
+
focused: true,
|
|
11149
|
+
insertSpaces
|
|
11150
|
+
};
|
|
11151
|
+
};
|
|
11152
|
+
|
|
10750
11153
|
const setLanguageId = async (editor, languageId, tokenizePath) => {
|
|
10751
11154
|
const {
|
|
10752
11155
|
tokenizerId
|
|
@@ -12589,6 +12992,10 @@ const getKeyBindings = () => {
|
|
|
12589
12992
|
command: 'Editor.fold',
|
|
12590
12993
|
key: CtrlCmd | Shift | BracketLeft,
|
|
12591
12994
|
when: FocusEditorText
|
|
12995
|
+
}, {
|
|
12996
|
+
command: 'Editor.goToBracket',
|
|
12997
|
+
key: CtrlCmd | Shift | Backslash,
|
|
12998
|
+
when: FocusEditorText
|
|
12592
12999
|
}, {
|
|
12593
13000
|
command: 'Editor.closeFind',
|
|
12594
13001
|
key: Escape,
|
|
@@ -12955,12 +13362,18 @@ const getQuickPickMenuEntries = () => {
|
|
|
12955
13362
|
}, {
|
|
12956
13363
|
id: 'Editor.goToDefinition',
|
|
12957
13364
|
label: editorGoToDefinition()
|
|
13365
|
+
}, {
|
|
13366
|
+
id: 'Editor.goToBracket',
|
|
13367
|
+
label: goToBracket()
|
|
12958
13368
|
}, {
|
|
12959
13369
|
id: 'Editor.goToTypeDefinition',
|
|
12960
13370
|
label: editorGoToTypeDefinition()
|
|
12961
13371
|
}, {
|
|
12962
13372
|
id: 'Editor.selectInsideString',
|
|
12963
13373
|
label: editorSelectInsideString()
|
|
13374
|
+
}, {
|
|
13375
|
+
id: 'Editor.selectToBracket',
|
|
13376
|
+
label: selectToBracket$1()
|
|
12964
13377
|
}, {
|
|
12965
13378
|
aliases: ['Indent More', 'DeIndent'],
|
|
12966
13379
|
id: 'Editor.indent',
|
|
@@ -13069,6 +13482,7 @@ const kFontSize = 'editor.fontSize';
|
|
|
13069
13482
|
const kFontFamily = 'editor.fontFamily';
|
|
13070
13483
|
const kLetterSpacing = 'editor.letterSpacing';
|
|
13071
13484
|
const kTabSize = 'editor.tabSize';
|
|
13485
|
+
const kInsertSpaces = 'editor.insertSpaces';
|
|
13072
13486
|
const kLineNumbers = 'editor.lineNumbers';
|
|
13073
13487
|
const kDiagnostics = 'editor.diagnostics';
|
|
13074
13488
|
const kQuickSuggestions = 'editor.quickSuggestions';
|
|
@@ -13111,6 +13525,9 @@ const getLetterSpacing = async () => {
|
|
|
13111
13525
|
const getTabSize = async () => {
|
|
13112
13526
|
return (await get$3(kTabSize)) || 2;
|
|
13113
13527
|
};
|
|
13528
|
+
const getInsertSpaces = async () => {
|
|
13529
|
+
return (await get$3(kInsertSpaces)) ?? true;
|
|
13530
|
+
};
|
|
13114
13531
|
const getLineNumbers = async () => {
|
|
13115
13532
|
return (await get$3(kLineNumbers)) ?? false;
|
|
13116
13533
|
};
|
|
@@ -13131,7 +13548,7 @@ const getBreadcrumbsEnabled = async () => {
|
|
|
13131
13548
|
};
|
|
13132
13549
|
|
|
13133
13550
|
const getEditorPreferences = async () => {
|
|
13134
|
-
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, breadcrumbsEnabled] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getBreadcrumbsEnabled()]);
|
|
13551
|
+
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, breadcrumbsEnabled, insertSpaces] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getBreadcrumbsEnabled(), getInsertSpaces()]);
|
|
13135
13552
|
return {
|
|
13136
13553
|
breadcrumbsEnabled,
|
|
13137
13554
|
completionTriggerCharacters,
|
|
@@ -13140,6 +13557,7 @@ const getEditorPreferences = async () => {
|
|
|
13140
13557
|
fontSize,
|
|
13141
13558
|
fontWeight,
|
|
13142
13559
|
hoverEnabled,
|
|
13560
|
+
insertSpaces,
|
|
13143
13561
|
isAutoClosingBracketsEnabled: isAutoClosingBracketsEnabled$1,
|
|
13144
13562
|
isAutoClosingQuotesEnabled: isAutoClosingQuotesEnabled$1,
|
|
13145
13563
|
isAutoClosingTagsEnabled: isAutoClosingTagsEnabled$1,
|
|
@@ -13204,8 +13622,7 @@ const applyTabCompletion = (editor, result) => {
|
|
|
13204
13622
|
};
|
|
13205
13623
|
|
|
13206
13624
|
const insertTab = editor => {
|
|
13207
|
-
|
|
13208
|
-
return type(editor, ' ');
|
|
13625
|
+
return type(editor, getIndentString(editor));
|
|
13209
13626
|
};
|
|
13210
13627
|
const handleTab = async editor => {
|
|
13211
13628
|
if (!isEverySelectionEmpty(editor.selections)) {
|
|
@@ -13475,6 +13892,7 @@ const loadContent = async (state, savedState) => {
|
|
|
13475
13892
|
fontSize,
|
|
13476
13893
|
fontWeight,
|
|
13477
13894
|
hoverEnabled,
|
|
13895
|
+
insertSpaces,
|
|
13478
13896
|
isAutoClosingBracketsEnabled,
|
|
13479
13897
|
isAutoClosingQuotesEnabled,
|
|
13480
13898
|
isAutoClosingTagsEnabled,
|
|
@@ -13505,6 +13923,7 @@ const loadContent = async (state, savedState) => {
|
|
|
13505
13923
|
fontSize,
|
|
13506
13924
|
fontWeight,
|
|
13507
13925
|
hoverEnabled,
|
|
13926
|
+
insertSpaces,
|
|
13508
13927
|
isAutoClosingBracketsEnabled,
|
|
13509
13928
|
isAutoClosingQuotesEnabled,
|
|
13510
13929
|
isAutoClosingTagsEnabled,
|
|
@@ -13527,9 +13946,12 @@ const loadContent = async (state, savedState) => {
|
|
|
13527
13946
|
}
|
|
13528
13947
|
}
|
|
13529
13948
|
let content = existingEditor ? getText$1(existingEditor) : '';
|
|
13949
|
+
let endOfLine = existingEditor?.endOfLine || 'lf';
|
|
13530
13950
|
try {
|
|
13531
13951
|
if (!existingEditor) {
|
|
13532
13952
|
content = await readFile$1(uri);
|
|
13953
|
+
endOfLine = getEndOfLine(content);
|
|
13954
|
+
content = normalizeLineEndings(content);
|
|
13533
13955
|
}
|
|
13534
13956
|
} catch (error) {
|
|
13535
13957
|
const newEditor1 = setBounds(newEditor0, x, y, width, height, 9);
|
|
@@ -13546,7 +13968,10 @@ const loadContent = async (state, savedState) => {
|
|
|
13546
13968
|
const savedHistory = existingEditor ? undefined : getSavedHistory(savedState, content);
|
|
13547
13969
|
|
|
13548
13970
|
// TODO avoid creating intermediate editors here
|
|
13549
|
-
const newEditor1 = setBounds(
|
|
13971
|
+
const newEditor1 = setBounds({
|
|
13972
|
+
...newEditor0,
|
|
13973
|
+
endOfLine
|
|
13974
|
+
}, x, y, width, height, 9);
|
|
13550
13975
|
const newEditor2 = setText$1(newEditor1, content);
|
|
13551
13976
|
let newEditor3 = newEditor2;
|
|
13552
13977
|
|
|
@@ -13700,6 +14125,13 @@ ${editorSelector} .EditorLineDecoration {
|
|
|
13700
14125
|
user-select: none;
|
|
13701
14126
|
}
|
|
13702
14127
|
${editorSelector} .R{background-color:#add6ff40}
|
|
14128
|
+
${editorSelector} .BracketMatch {
|
|
14129
|
+
position: absolute;
|
|
14130
|
+
box-sizing: border-box;
|
|
14131
|
+
border: 1px solid var(--EditorBracketMatchBorder, rgba(128, 128, 128, 0.8));
|
|
14132
|
+
background: var(--EditorBracketMatchBackground, rgba(128, 128, 128, 0.25));
|
|
14133
|
+
pointer-events: none;
|
|
14134
|
+
}
|
|
13703
14135
|
${editorSelector} .ScrollBarThumbVertical {
|
|
13704
14136
|
height: var(--ScrollBarHeight);
|
|
13705
14137
|
translate: 0px var(--ScrollBarTop);
|
|
@@ -14154,6 +14586,23 @@ const getEditorCursorsVirtualDom = cursorInfos => {
|
|
|
14154
14586
|
}, ...cursorsDom];
|
|
14155
14587
|
};
|
|
14156
14588
|
|
|
14589
|
+
const getBracketMatchesVirtualDom = infos => {
|
|
14590
|
+
return infos.map(({
|
|
14591
|
+
height,
|
|
14592
|
+
width,
|
|
14593
|
+
x,
|
|
14594
|
+
y
|
|
14595
|
+
}) => ({
|
|
14596
|
+
childCount: 0,
|
|
14597
|
+
className: 'BracketMatch',
|
|
14598
|
+
height,
|
|
14599
|
+
left: x,
|
|
14600
|
+
top: y,
|
|
14601
|
+
type: Div,
|
|
14602
|
+
width
|
|
14603
|
+
}));
|
|
14604
|
+
};
|
|
14605
|
+
|
|
14157
14606
|
// TODO use numeric value
|
|
14158
14607
|
const Error$1 = 'error';
|
|
14159
14608
|
const Warning = 'warning';
|
|
@@ -14194,13 +14643,14 @@ const getDiagnosticsVirtualDom = diagnostics => {
|
|
|
14194
14643
|
return dom;
|
|
14195
14644
|
};
|
|
14196
14645
|
|
|
14197
|
-
const getEditorDiagnosticsVirtualDom = diagnostics => {
|
|
14646
|
+
const getEditorDiagnosticsVirtualDom = (diagnostics, bracketMatchInfos = []) => {
|
|
14198
14647
|
const diagnosticsDom = getDiagnosticsVirtualDom([...diagnostics]);
|
|
14648
|
+
const bracketMatchesDom = getBracketMatchesVirtualDom(bracketMatchInfos);
|
|
14199
14649
|
return [{
|
|
14200
|
-
childCount: diagnostics.length,
|
|
14650
|
+
childCount: diagnostics.length + bracketMatchInfos.length,
|
|
14201
14651
|
className: 'LayerDiagnostics',
|
|
14202
14652
|
type: Div
|
|
14203
|
-
}, ...diagnosticsDom];
|
|
14653
|
+
}, ...diagnosticsDom, ...bracketMatchesDom];
|
|
14204
14654
|
};
|
|
14205
14655
|
|
|
14206
14656
|
const editorLineDecorationNode = {
|
|
@@ -14286,8 +14736,8 @@ const editorLayersNode = {
|
|
|
14286
14736
|
className: 'EditorLayers',
|
|
14287
14737
|
type: Div
|
|
14288
14738
|
};
|
|
14289
|
-
const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = []) => {
|
|
14290
|
-
return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics)];
|
|
14739
|
+
const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = []) => {
|
|
14740
|
+
return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
|
|
14291
14741
|
};
|
|
14292
14742
|
|
|
14293
14743
|
const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
|
|
@@ -14344,6 +14794,7 @@ const editorContentNode = {
|
|
|
14344
14794
|
type: Div
|
|
14345
14795
|
};
|
|
14346
14796
|
const getEditorContentVirtualDom = ({
|
|
14797
|
+
bracketMatchInfos = [],
|
|
14347
14798
|
cursorInfos = [],
|
|
14348
14799
|
diagnostics = [],
|
|
14349
14800
|
differences,
|
|
@@ -14355,7 +14806,7 @@ const getEditorContentVirtualDom = ({
|
|
|
14355
14806
|
textInfos,
|
|
14356
14807
|
visibleLineIndices = []
|
|
14357
14808
|
}) => {
|
|
14358
|
-
return [editorContentNode, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
|
|
14809
|
+
return [editorContentNode, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
|
|
14359
14810
|
};
|
|
14360
14811
|
|
|
14361
14812
|
const getGutterInfoVirtualDom = gutterInfo => {
|
|
@@ -14445,6 +14896,7 @@ const getMinimapVirtualDom = (minimapEnabled, minimapLines, minLineY) => {
|
|
|
14445
14896
|
}];
|
|
14446
14897
|
};
|
|
14447
14898
|
const getEditorVirtualDom = ({
|
|
14899
|
+
bracketMatchInfos = [],
|
|
14448
14900
|
breadcrumbsEnabled = false,
|
|
14449
14901
|
breakPoints = [],
|
|
14450
14902
|
cursorInfos = [],
|
|
@@ -14502,6 +14954,7 @@ const getEditorVirtualDom = ({
|
|
|
14502
14954
|
role: Code,
|
|
14503
14955
|
type: Div
|
|
14504
14956
|
}, ...breadcrumbsDom, ...gutterDom, ...getEditorContentVirtualDom({
|
|
14957
|
+
bracketMatchInfos,
|
|
14505
14958
|
cursorInfos,
|
|
14506
14959
|
diagnostics,
|
|
14507
14960
|
differences,
|
|
@@ -14735,10 +15188,12 @@ const renderAdditionalFocusContext = {
|
|
|
14735
15188
|
};
|
|
14736
15189
|
const renderDecorations = {
|
|
14737
15190
|
apply(oldState, newState) {
|
|
14738
|
-
const
|
|
15191
|
+
const diagnosticsDom = getDiagnosticsVirtualDom(newState.visualDecorations || []);
|
|
15192
|
+
const bracketMatchesDom = getBracketMatchesVirtualDom(newState.bracketMatchInfos || []);
|
|
15193
|
+
const dom = [...diagnosticsDom, ...bracketMatchesDom];
|
|
14739
15194
|
return ['setDecorationsDom', dom];
|
|
14740
15195
|
},
|
|
14741
|
-
isEqual: (oldState, newState) => oldState.visualDecorations === newState.visualDecorations
|
|
15196
|
+
isEqual: (oldState, newState) => oldState.visualDecorations === newState.visualDecorations && oldState.bracketMatchInfos === newState.bracketMatchInfos
|
|
14742
15197
|
};
|
|
14743
15198
|
const renderGutterInfo = {
|
|
14744
15199
|
apply(oldState, newState) {
|
|
@@ -15115,7 +15570,9 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
|
|
|
15115
15570
|
const state = oldInstance.newState;
|
|
15116
15571
|
const {
|
|
15117
15572
|
cursorUndoStack,
|
|
15573
|
+
endOfLine,
|
|
15118
15574
|
initial,
|
|
15575
|
+
insertSpaces,
|
|
15119
15576
|
isSelecting,
|
|
15120
15577
|
lines,
|
|
15121
15578
|
modified,
|
|
@@ -15155,7 +15612,7 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
|
|
|
15155
15612
|
set$8(uid, state, finalEditor);
|
|
15156
15613
|
}
|
|
15157
15614
|
await notifyEditorStatusChange(state, finalEditor);
|
|
15158
|
-
if (!initial && uri === finalEditor.uri && (lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
15615
|
+
if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
15159
15616
|
for (const key of getKeys$2()) {
|
|
15160
15617
|
const otherUid = Number(key);
|
|
15161
15618
|
const instance = get$8(otherUid);
|
|
@@ -15167,7 +15624,9 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
|
|
|
15167
15624
|
...editor,
|
|
15168
15625
|
decorations: finalEditor.decorations,
|
|
15169
15626
|
diagnostics: finalEditor.diagnostics,
|
|
15627
|
+
endOfLine: finalEditor.endOfLine,
|
|
15170
15628
|
incrementalEdits: emptyIncrementalEdits,
|
|
15629
|
+
insertSpaces: finalEditor.insertSpaces,
|
|
15171
15630
|
invalidStartIndex: Math.min(editor.invalidStartIndex, finalEditor.invalidStartIndex),
|
|
15172
15631
|
lines: finalEditor.lines,
|
|
15173
15632
|
modified: finalEditor.modified,
|
|
@@ -15289,6 +15748,7 @@ const commandMap = {
|
|
|
15289
15748
|
'Editor.getWordAtOffset2': getWordAtOffset2,
|
|
15290
15749
|
'Editor.getWordBefore': getWordBefore,
|
|
15291
15750
|
'Editor.getWordBefore2': getWordBefore2,
|
|
15751
|
+
'Editor.goToBracket': wrapCommand(goToBracket$1),
|
|
15292
15752
|
'Editor.goToDefinition': wrapCommand(goToDefinition),
|
|
15293
15753
|
'Editor.goToTypeDefinition': wrapCommand(goToTypeDefinition),
|
|
15294
15754
|
'Editor.handleBeforeInput': wrapCommand(handleBeforeInput, true),
|
|
@@ -15372,6 +15832,7 @@ const commandMap = {
|
|
|
15372
15832
|
'Editor.selectLine': wrapCommand(selectLine),
|
|
15373
15833
|
'Editor.selectNextOccurrence': wrapCommand(selectNextOccurrence),
|
|
15374
15834
|
'Editor.selectPreviousOccurrence': wrapCommand(selectPreviousOccurrence),
|
|
15835
|
+
'Editor.selectToBracket': wrapCommand(selectToBracket),
|
|
15375
15836
|
'Editor.selectUp': wrapCommand(selectUp),
|
|
15376
15837
|
'Editor.selectWord': wrapCommand(selectWord),
|
|
15377
15838
|
'Editor.selectWordLeft': wrapCommand(selectWordLeft),
|
|
@@ -15381,6 +15842,8 @@ const commandMap = {
|
|
|
15381
15842
|
'Editor.setDelta': wrapCommand(setDelta),
|
|
15382
15843
|
'Editor.setDeltaY': wrapCommand(setDeltaY),
|
|
15383
15844
|
'Editor.setDiagnostics': wrapCommand(addDiagnostics),
|
|
15845
|
+
'Editor.setEndOfLine': wrapCommand(setEndOfLine),
|
|
15846
|
+
'Editor.setIndentation': wrapCommand(setIndentation),
|
|
15384
15847
|
'Editor.setLanguageId': wrapCommand(setLanguageId),
|
|
15385
15848
|
'Editor.setSelections': wrapCommand(setSelections),
|
|
15386
15849
|
'Editor.setSelections2': setSelections2,
|