@lvce-editor/editor-worker 19.49.0 → 19.50.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.
@@ -1199,7 +1199,7 @@ const create$a = rpcId => {
1199
1199
  };
1200
1200
 
1201
1201
  const Audio = 0;
1202
- const Button$2 = 1;
1202
+ const Button$3 = 1;
1203
1203
  const Col = 2;
1204
1204
  const ColGroup = 3;
1205
1205
  const Div$1 = 4;
@@ -1290,7 +1290,7 @@ const VirtualDomElements = {
1290
1290
  Audio,
1291
1291
  BlockQuote,
1292
1292
  Br,
1293
- Button: Button$2,
1293
+ Button: Button$3,
1294
1294
  Canvas,
1295
1295
  Circle,
1296
1296
  Cite,
@@ -1368,7 +1368,7 @@ const VirtualDomElements = {
1368
1368
  };
1369
1369
 
1370
1370
  const AltKey = 'event.altKey';
1371
- const Button$1 = 'event.button';
1371
+ const Button$2 = 'event.button';
1372
1372
  const ClientX = 'event.clientX';
1373
1373
  const ClientY = 'event.clientY';
1374
1374
  const DeltaMode = 'event.deltaMode';
@@ -2008,6 +2008,103 @@ const clamp = (num, min, max) => {
2008
2008
  return Math.min(Math.max(num, min), max);
2009
2009
  };
2010
2010
 
2011
+ const toMergeConflictActionsRow = rowIndex => ~rowIndex;
2012
+ const isMergeConflictActionsRow = viewRow => viewRow < 0;
2013
+ const getMergeConflictRowIndex = viewRow => ~viewRow;
2014
+ const getViewLineIndices = (lineCount, isRowHidden, mergeConflicts) => {
2015
+ const conflictStartRows = new Set(mergeConflicts.map(conflict => conflict.startRowIndex));
2016
+ const result = [];
2017
+ for (let rowIndex = 0; rowIndex < lineCount; rowIndex++) {
2018
+ if (isRowHidden(rowIndex)) {
2019
+ continue;
2020
+ }
2021
+ if (conflictStartRows.has(rowIndex)) {
2022
+ result.push(toMergeConflictActionsRow(rowIndex));
2023
+ }
2024
+ result.push(rowIndex);
2025
+ }
2026
+ return result;
2027
+ };
2028
+ const getVisibleViewLineIndices = (viewLineIndices, startVisualRow, numberOfVisibleLines) => {
2029
+ return viewLineIndices.slice(startVisualRow, startVisualRow + numberOfVisibleLines);
2030
+ };
2031
+ const getVisibleLineIndices = visibleViewLineIndices => {
2032
+ return visibleViewLineIndices.filter(viewRow => !isMergeConflictActionsRow(viewRow));
2033
+ };
2034
+ const getVisualRowForDocumentRow$1 = (rowIndex, viewLineIndices) => {
2035
+ const visualRow = viewLineIndices.indexOf(rowIndex);
2036
+ return visualRow === -1 ? rowIndex : visualRow;
2037
+ };
2038
+ const getDocumentRowForVisualRow$1 = (visualRow, viewLineIndices) => {
2039
+ if (visualRow < 0 || visualRow >= viewLineIndices.length) {
2040
+ return visualRow;
2041
+ }
2042
+ const viewRow = viewLineIndices[visualRow];
2043
+ return isMergeConflictActionsRow(viewRow) ? getMergeConflictRowIndex(viewRow) : viewRow;
2044
+ };
2045
+
2046
+ const isStartMarker = line => /^<{7}(?: .*)?$/.test(line);
2047
+ const isBaseMarker = line => /^\|{7}(?: .*)?$/.test(line);
2048
+ const isSeparatorMarker = line => /^={7}$/.test(line);
2049
+ const isEndMarker = line => /^>{7}(?: .*)?$/.test(line);
2050
+ const getMergeConflict = (lines, startRowIndex) => {
2051
+ let baseMarkerRowIndex = -1;
2052
+ let separatorRowIndex = -1;
2053
+ let endRowIndex = -1;
2054
+ for (let rowIndex = startRowIndex + 1; rowIndex < lines.length; rowIndex++) {
2055
+ const line = lines[rowIndex];
2056
+ if (isStartMarker(line)) {
2057
+ return undefined;
2058
+ }
2059
+ if (separatorRowIndex === -1 && baseMarkerRowIndex === -1 && isBaseMarker(line)) {
2060
+ baseMarkerRowIndex = rowIndex;
2061
+ continue;
2062
+ }
2063
+ if (separatorRowIndex === -1 && isSeparatorMarker(line)) {
2064
+ separatorRowIndex = rowIndex;
2065
+ continue;
2066
+ }
2067
+ if (isEndMarker(line)) {
2068
+ endRowIndex = rowIndex;
2069
+ break;
2070
+ }
2071
+ }
2072
+ if (separatorRowIndex === -1 || endRowIndex === -1 || baseMarkerRowIndex > separatorRowIndex) {
2073
+ return undefined;
2074
+ }
2075
+ const currentEndRowIndex = baseMarkerRowIndex === -1 ? separatorRowIndex : baseMarkerRowIndex;
2076
+ return {
2077
+ baseEndRowIndex: separatorRowIndex,
2078
+ baseStartRowIndex: baseMarkerRowIndex === -1 ? separatorRowIndex : baseMarkerRowIndex + 1,
2079
+ currentEndRowIndex,
2080
+ currentStartRowIndex: startRowIndex + 1,
2081
+ endRowIndex,
2082
+ incomingEndRowIndex: endRowIndex,
2083
+ incomingStartRowIndex: separatorRowIndex + 1,
2084
+ separatorRowIndex,
2085
+ startRowIndex
2086
+ };
2087
+ };
2088
+ const getMergeConflicts = lines => {
2089
+ const conflicts = [];
2090
+ let rowIndex = 0;
2091
+ while (rowIndex < lines.length) {
2092
+ if (!isStartMarker(lines[rowIndex])) {
2093
+ rowIndex++;
2094
+ continue;
2095
+ }
2096
+ const conflict = getMergeConflict(lines, rowIndex);
2097
+ if (conflict) {
2098
+ conflicts.push(conflict);
2099
+ rowIndex = conflict.endRowIndex + 1;
2100
+ continue;
2101
+ }
2102
+ const nextEndMarker = lines.findIndex((line, index) => index > rowIndex && isEndMarker(line));
2103
+ rowIndex = (nextEndMarker === -1 ? rowIndex : nextEndMarker) + 1;
2104
+ }
2105
+ return conflicts;
2106
+ };
2107
+
2011
2108
  const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
2012
2109
  const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
2013
2110
  if (!Number.isFinite(scrollBarOffset)) {
@@ -2057,6 +2154,14 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
2057
2154
  const getSortedRanges = ranges => {
2058
2155
  return ranges.toSorted((a, b) => a.start - b.start || b.end - a.end);
2059
2156
  };
2157
+ const isRowHidden = (rowIndex, ranges) => {
2158
+ for (const range of ranges) {
2159
+ if (rowIndex > range.start && rowIndex <= range.end) {
2160
+ return true;
2161
+ }
2162
+ }
2163
+ return false;
2164
+ };
2060
2165
  const getUnhiddenRow = (rowIndex, previousRowIndex, lineCount, ranges) => {
2061
2166
  for (const range of ranges) {
2062
2167
  if (rowIndex > range.start && rowIndex <= range.end) {
@@ -2123,12 +2228,16 @@ const updateLayout = (editor, foldingRanges) => {
2123
2228
  numberOfVisibleLines,
2124
2229
  rowHeight
2125
2230
  } = editor;
2126
- const visibleLineCount = getVisibleLineCount(lines.length, foldingRanges);
2231
+ const mergeConflicts = editor.mergeConflictActionsEnabled ? getMergeConflicts(lines) : [];
2232
+ const hasMergeConflictRows = mergeConflicts.length > 0;
2233
+ const viewLineIndices = hasMergeConflictRows ? getViewLineIndices(lines.length, rowIndex => isRowHidden(rowIndex, foldingRanges), mergeConflicts) : [];
2234
+ const visibleLineCount = hasMergeConflictRows ? viewLineIndices.length : getVisibleLineCount(lines.length, foldingRanges);
2127
2235
  const finalY = Math.max(visibleLineCount - numberOfVisibleLines, 0);
2128
2236
  const finalDeltaY = finalY * itemHeight;
2129
2237
  const deltaY = clamp(editor.deltaY, 0, finalDeltaY);
2130
2238
  const startVisualRow = Math.floor(deltaY / itemHeight);
2131
- const visibleLineIndices = getViewportLineIndices(lines.length, foldingRanges, startVisualRow, numberOfVisibleLines);
2239
+ const visibleViewLineIndices = hasMergeConflictRows ? getVisibleViewLineIndices(viewLineIndices, startVisualRow, numberOfVisibleLines) : getViewportLineIndices(lines.length, foldingRanges, startVisualRow, numberOfVisibleLines);
2240
+ const visibleLineIndices = hasMergeConflictRows ? getVisibleLineIndices(visibleViewLineIndices) : visibleViewLineIndices;
2132
2241
  const minLineY = visibleLineIndices[0] ?? 0;
2133
2242
  const maxLineY = visibleLineIndices.length === 0 ? 0 : visibleLineIndices.at(-1) + 1;
2134
2243
  const contentHeight = visibleLineCount * rowHeight;
@@ -2141,10 +2250,13 @@ const updateLayout = (editor, foldingRanges) => {
2141
2250
  finalY,
2142
2251
  foldingRanges,
2143
2252
  maxLineY,
2253
+ mergeConflicts,
2144
2254
  minLineY,
2145
2255
  scrollBarHeight,
2146
2256
  scrollBarY,
2147
- visibleLineIndices
2257
+ viewLineIndices,
2258
+ visibleLineIndices,
2259
+ visibleViewLineIndices
2148
2260
  };
2149
2261
  };
2150
2262
  const addRange = (ranges, range) => {
@@ -3288,22 +3400,20 @@ const setDeltaY$1 = async (state, value) => {
3288
3400
  if (deltaY === newDeltaY) {
3289
3401
  return state;
3290
3402
  }
3291
- const minLineY = Math.floor(newDeltaY / itemHeight);
3292
- const maxLineY = minLineY + numberOfVisibleLines;
3293
- const newEditor1 = state.foldingRanges?.length > 0 ? updateLayout({
3294
- ...state,
3295
- deltaY: newDeltaY
3296
- }, state.foldingRanges) : {
3403
+ const startVisualRow = Math.floor(newDeltaY / itemHeight);
3404
+ const hasMergeConflictRows = state.viewLineIndices?.length > 0;
3405
+ const visibleViewLineIndices = hasMergeConflictRows ? getVisibleViewLineIndices(state.viewLineIndices, startVisualRow, numberOfVisibleLines) : getViewportLineIndices(state.lines.length, state.foldingRanges || [], startVisualRow, numberOfVisibleLines);
3406
+ const visibleLineIndices = hasMergeConflictRows ? getVisibleLineIndices(visibleViewLineIndices) : visibleViewLineIndices;
3407
+ const minLineY = visibleLineIndices[0] ?? 0;
3408
+ const maxLineY = visibleLineIndices.length === 0 ? 0 : visibleLineIndices.at(-1) + 1;
3409
+ const newEditor1 = {
3297
3410
  ...state,
3298
3411
  deltaY: newDeltaY,
3299
3412
  maxLineY,
3300
3413
  minLineY,
3301
3414
  scrollBarY: getScrollBarY(newDeltaY, finalDeltaY, height, scrollBarHeight),
3302
- ...('visibleLineIndices' in state && {
3303
- visibleLineIndices: Array.from({
3304
- length: Math.max(Math.min(maxLineY, state.lines.length) - minLineY, 0)
3305
- }, (_, index) => minLineY + index)
3306
- })
3415
+ visibleLineIndices,
3416
+ visibleViewLineIndices
3307
3417
  };
3308
3418
  const syncIncremental = getEnabled();
3309
3419
  const {
@@ -3847,7 +3957,9 @@ const getVisible = async editor => {
3847
3957
  rowHeight,
3848
3958
  selections,
3849
3959
  tabSize,
3960
+ viewLineIndices,
3850
3961
  visibleLineIndices,
3962
+ visibleViewLineIndices,
3851
3963
  width
3852
3964
  } = editor;
3853
3965
  const averageCharWidth = charWidth;
@@ -3855,18 +3967,20 @@ const getVisible = async editor => {
3855
3967
  const actualVisibleLineIndices = visibleLineIndices || Array.from({
3856
3968
  length: maxLineY - minLineY
3857
3969
  }, (_, index) => minLineY + index);
3858
- const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : getVisualRowForDocumentRow(minLineY, foldingRanges);
3859
- const endVisualRow = startVisualRow + actualVisibleLineIndices.length;
3860
- const getRelativeRow = rowIndex => getVisualRowForDocumentRow(rowIndex, foldingRanges) - startVisualRow;
3970
+ const getVisualRow = rowIndex => viewLineIndices ? getVisualRowForDocumentRow$1(rowIndex, viewLineIndices) : getVisualRowForDocumentRow(rowIndex, foldingRanges);
3971
+ const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : getVisualRow(minLineY);
3972
+ const endVisualRow = startVisualRow + (visibleViewLineIndices?.length || actualVisibleLineIndices.length);
3973
+ const getRelativeRow = rowIndex => getVisualRow(rowIndex) - startVisualRow;
3974
+ const getDifference = rowIndex => differences[actualVisibleLineIndices.indexOf(rowIndex)];
3861
3975
  for (let i = 0; i < selections.length; i += 4) {
3862
3976
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn, reversed] = getSelectionPairs(selections, i);
3863
- const selectionStartVisualRow = getVisualRowForDocumentRow(selectionStartRow, foldingRanges);
3864
- const selectionEndVisualRow = getVisualRowForDocumentRow(selectionEndRow, foldingRanges);
3977
+ const selectionStartVisualRow = getVisualRow(selectionStartRow);
3978
+ const selectionEndVisualRow = getVisualRow(selectionEndRow);
3865
3979
  if (selectionEndVisualRow < startVisualRow || selectionStartVisualRow >= endVisualRow) {
3866
3980
  continue;
3867
3981
  }
3868
3982
  const relativeEndLineRow = getRelativeRow(selectionEndRow);
3869
- const endLineDifference = differences[relativeEndLineRow];
3983
+ const endLineDifference = getDifference(selectionEndRow);
3870
3984
  const endLine = lines[selectionEndRow];
3871
3985
  const endLineEndX = await getX(endLine, selectionEndColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, endLineDifference);
3872
3986
  const endLineY = relativeEndLineRow * rowHeight;
@@ -3876,7 +3990,7 @@ const getVisible = async editor => {
3876
3990
  }
3877
3991
  const startLineYRelative = getRelativeRow(selectionStartRow);
3878
3992
  const startLineY = startLineYRelative * rowHeight;
3879
- const startLineDifference = differences[startLineYRelative];
3993
+ const startLineDifference = getDifference(selectionStartRow);
3880
3994
  if (selectionStartRow === selectionEndRow) {
3881
3995
  const startX = await getX(endLine, selectionStartColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, startLineDifference);
3882
3996
  if (reversed) {
@@ -3903,7 +4017,7 @@ const getVisible = async editor => {
3903
4017
  const currentLine = lines[rowIndex];
3904
4018
  const relativeLine = getRelativeRow(rowIndex);
3905
4019
  const currentLineY = relativeLine * rowHeight;
3906
- const difference = differences[relativeLine];
4020
+ const difference = getDifference(rowIndex);
3907
4021
  const selectionWidth = await getX(currentLine, currentLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference);
3908
4022
  visibleSelections.push(0, currentLineY, selectionWidth, rowHeight);
3909
4023
  }
@@ -3967,7 +4081,7 @@ const setSelections$2 = (editor, selections) => {
3967
4081
  });
3968
4082
  const previousActiveRowIndex = editor.selections[primarySelectionIndex + 2] ?? activeRowIndex;
3969
4083
  const rowIndex = getUnhiddenRow(activeRowIndex, previousActiveRowIndex, editor.lines.length, foldingRanges);
3970
- const visualRow = getVisualRowForDocumentRow(rowIndex, foldingRanges);
4084
+ const visualRow = editor.viewLineIndices ? getVisualRowForDocumentRow$1(rowIndex, editor.viewLineIndices) : getVisualRowForDocumentRow(rowIndex, foldingRanges);
3971
4085
  const startVisualRow = Math.floor(editor.deltaY / editor.itemHeight);
3972
4086
  const endVisualRow = startVisualRow + editor.numberOfVisibleLines;
3973
4087
  if (visualRow >= startVisualRow && visualRow < endVisualRow) {
@@ -4718,9 +4832,9 @@ const getInfo = async (editor, position, visibleLineIndices, startVisualRow) =>
4718
4832
  tabSize,
4719
4833
  width
4720
4834
  } = editor;
4721
- const visualRow = getVisualRowForDocumentRow(position.rowIndex, foldingRanges);
4835
+ const visualRow = editor.viewLineIndices ? getVisualRowForDocumentRow$1(position.rowIndex, editor.viewLineIndices) : getVisualRowForDocumentRow(position.rowIndex, foldingRanges);
4722
4836
  const relativeRow = visualRow - startVisualRow;
4723
- const difference = differences[relativeRow] ?? 0;
4837
+ const difference = differences[visibleLineIndices.indexOf(position.rowIndex)] ?? 0;
4724
4838
  const line = lines[position.rowIndex];
4725
4839
  const x = await getX(line, position.columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth, difference);
4726
4840
  const endX = await getX(line, position.columnIndex + 1, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth, difference);
@@ -4740,12 +4854,13 @@ const getVisibleBracketMatches = async editor => {
4740
4854
  maxLineY,
4741
4855
  minLineY,
4742
4856
  selections,
4857
+ viewLineIndices,
4743
4858
  visibleLineIndices
4744
4859
  } = editor;
4745
4860
  const actualVisibleLineIndices = visibleLineIndices || Array.from({
4746
4861
  length: maxLineY - minLineY
4747
4862
  }, (_, index) => minLineY + index);
4748
- const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : getVisualRowForDocumentRow(minLineY, foldingRanges);
4863
+ const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : viewLineIndices ? getVisualRowForDocumentRow$1(minLineY, viewLineIndices) : getVisualRowForDocumentRow(minLineY, foldingRanges);
4749
4864
  const positions = new Map();
4750
4865
  for (let i = 0; i < selections.length; i += 4) {
4751
4866
  const startRowIndex = selections[i];
@@ -4770,25 +4885,24 @@ const getDiagnosticType = diagnostic => {
4770
4885
  return diagnostic.type;
4771
4886
  };
4772
4887
 
4773
- const getY = (row, minLineY, rowHeight) => {
4774
- return (row - minLineY) * rowHeight;
4775
- };
4776
-
4777
4888
  const getVisibleDiagnostics = async (editor, diagnostics) => {
4778
4889
  const visibleDiagnostics = [];
4779
4890
  const {
4780
4891
  charWidth,
4892
+ deltaY,
4781
4893
  fontFamily,
4782
4894
  fontSize,
4783
4895
  fontWeight,
4784
4896
  isMonospaceFont,
4897
+ itemHeight,
4785
4898
  letterSpacing,
4786
4899
  lines,
4787
- minLineY,
4788
4900
  rowHeight,
4789
4901
  tabSize,
4902
+ viewLineIndices,
4790
4903
  width
4791
4904
  } = editor;
4905
+ const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : editor.minLineY || 0;
4792
4906
  for (const diagnostic of diagnostics) {
4793
4907
  const {
4794
4908
  columnIndex,
@@ -4800,7 +4914,8 @@ const getVisibleDiagnostics = async (editor, diagnostics) => {
4800
4914
  const endLineDifference = 0;
4801
4915
  const halfCursorWidth = 0;
4802
4916
  const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
4803
- const y = getY(rowIndex, minLineY, rowHeight);
4917
+ const visualRow = viewLineIndices ? getVisualRowForDocumentRow$1(rowIndex, viewLineIndices) : rowIndex;
4918
+ const y = (visualRow - startVisualRow) * rowHeight;
4804
4919
  visibleDiagnostics.push({
4805
4920
  height: rowHeight,
4806
4921
  type: getDiagnosticType(diagnostic),
@@ -4816,26 +4931,41 @@ const shouldUpdateDiagnosticData = (oldState, newState) => {
4816
4931
  return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.minLineY !== newState.minLineY || 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.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
4817
4932
  };
4818
4933
  const shouldUpdateSelectionData = (oldState, newState) => {
4819
- 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;
4934
+ return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || 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;
4820
4935
  };
4821
4936
  const shouldUpdateBracketMatchData = (oldState, newState) => {
4822
4937
  if (!('bracketMatchInfos' in newState)) {
4823
4938
  return false;
4824
4939
  }
4825
- 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;
4940
+ return oldState.selections !== newState.selections || oldState.lines !== newState.lines || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || 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;
4826
4941
  };
4827
4942
  const shouldUpdateLightBulb = (oldState, newState) => oldState.diagnostics !== newState.diagnostics || oldState.languageId !== newState.languageId || oldState.selections !== newState.selections || oldState.uri !== newState.uri;
4828
4943
  const shouldUpdateVisibleTextData = (oldState, newState) => {
4829
4944
  if (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences) {
4830
4945
  return false;
4831
4946
  }
4832
- return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
4947
+ return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
4833
4948
  };
4834
4949
  const shouldUpdateMinimapData = (oldState, newState) => {
4835
4950
  return newState.minimapEnabled && (!oldState.minimapEnabled || oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId);
4836
4951
  };
4952
+ const mergeConflictsEqual$1 = (oldState, newState) => {
4953
+ const oldConflicts = oldState.mergeConflicts || [];
4954
+ const newConflicts = newState.mergeConflicts || [];
4955
+ if (oldConflicts.length !== newConflicts.length) {
4956
+ return false;
4957
+ }
4958
+ return oldConflicts.every((conflict, index) => {
4959
+ const other = newConflicts[index];
4960
+ return conflict.startRowIndex === other.startRowIndex && conflict.endRowIndex === other.endRowIndex;
4961
+ });
4962
+ };
4837
4963
  const updateDerivedState = async (oldState, newState) => {
4838
- const nextState = oldState.lines !== newState.lines && 'foldingRanges' in newState ? updateLayout(newState, []) : newState;
4964
+ const layoutState = oldState.lines !== newState.lines && 'foldingRanges' in newState ? updateLayout(newState, []) : newState;
4965
+ const nextState = mergeConflictsEqual$1(oldState, layoutState) ? layoutState : {
4966
+ ...layoutState,
4967
+ incrementalEdits: emptyIncrementalEdits
4968
+ };
4839
4969
  let finalState = nextState;
4840
4970
  if (shouldUpdateVisibleTextData(oldState, nextState)) {
4841
4971
  const syncIncremental = getEnabled();
@@ -5063,6 +5193,8 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
5063
5193
  lines: [],
5064
5194
  longestLineWidth: 0,
5065
5195
  maxLineY: 0,
5196
+ mergeConflictActionsEnabled: false,
5197
+ mergeConflicts: [],
5066
5198
  minimapEnabled: false,
5067
5199
  minimapLines: [],
5068
5200
  minimapRevision: 0,
@@ -5102,7 +5234,9 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
5102
5234
  undoStack: [],
5103
5235
  uri,
5104
5236
  validLines: [],
5237
+ viewLineIndices: [],
5105
5238
  visibleLineIndices: [],
5239
+ visibleViewLineIndices: [],
5106
5240
  visualDecorations: [],
5107
5241
  widgetRevision: 0,
5108
5242
  widgets: [],
@@ -5145,6 +5279,8 @@ const emptyEditor = {
5145
5279
  lines: [],
5146
5280
  longestLineWidth: 0,
5147
5281
  maxLineY: 0,
5282
+ mergeConflictActionsEnabled: false,
5283
+ mergeConflicts: [],
5148
5284
  minimapEnabled: false,
5149
5285
  minimapLines: [],
5150
5286
  minimapRevision: 0,
@@ -5172,7 +5308,9 @@ const emptyEditor = {
5172
5308
  tokenizerId: 0,
5173
5309
  undoStack: [],
5174
5310
  uri: '',
5311
+ viewLineIndices: [],
5175
5312
  visibleLineIndices: [],
5313
+ visibleViewLineIndices: [],
5176
5314
  width: 0,
5177
5315
  workspaceUri: '',
5178
5316
  x: 0,
@@ -5359,6 +5497,8 @@ const createEditor = async ({
5359
5497
  lines: [],
5360
5498
  longestLineWidth: 0,
5361
5499
  maxLineY: 0,
5500
+ mergeConflictActionsEnabled: false,
5501
+ mergeConflicts: [],
5362
5502
  minimumSliderSize: 20,
5363
5503
  minLineY: 0,
5364
5504
  modified: false,
@@ -5394,7 +5534,9 @@ const createEditor = async ({
5394
5534
  uri,
5395
5535
  useFunctionalRendering,
5396
5536
  validLines: [],
5537
+ viewLineIndices: [],
5397
5538
  visibleLineIndices: [],
5539
+ visibleViewLineIndices: [],
5398
5540
  widgetRevision: 0,
5399
5541
  widgets: [],
5400
5542
  width,
@@ -5535,7 +5677,7 @@ const isEqual$3 = (oldState, newState) => {
5535
5677
  };
5536
5678
 
5537
5679
  const isEqual$2 = (oldState, newState) => {
5538
- 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.focused === newState.focused && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && 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;
5680
+ 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.focused === newState.focused && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
5539
5681
  };
5540
5682
 
5541
5683
  const isEqual$1 = (oldState, newState) => {
@@ -5749,6 +5891,58 @@ const disposeEditor = async editorUid => {
5749
5891
  return commands;
5750
5892
  };
5751
5893
 
5894
+ const getAcceptedLines = (lines, conflict, action) => {
5895
+ const current = lines.slice(conflict.currentStartRowIndex, conflict.currentEndRowIndex);
5896
+ const incoming = lines.slice(conflict.incomingStartRowIndex, conflict.incomingEndRowIndex);
5897
+ switch (action) {
5898
+ case 'both':
5899
+ return [...current, ...incoming];
5900
+ case 'current':
5901
+ return current;
5902
+ case 'incoming':
5903
+ return incoming;
5904
+ default:
5905
+ return undefined;
5906
+ }
5907
+ };
5908
+ const acceptMergeConflict = async (state, action, rowIndexValue) => {
5909
+ const rowIndex = Number(rowIndexValue);
5910
+ if (!Number.isSafeInteger(rowIndex)) {
5911
+ return state;
5912
+ }
5913
+ const conflict = getMergeConflicts(state.lines).find(candidate => candidate.startRowIndex === rowIndex);
5914
+ if (!conflict) {
5915
+ return state;
5916
+ }
5917
+ const acceptedLines = getAcceptedLines(state.lines, conflict, action);
5918
+ if (!acceptedLines) {
5919
+ return state;
5920
+ }
5921
+ const inserted = acceptedLines.length === 0 ? [''] : acceptedLines;
5922
+ const start = {
5923
+ columnIndex: 0,
5924
+ rowIndex: conflict.startRowIndex
5925
+ };
5926
+ const end = {
5927
+ columnIndex: state.lines[conflict.endRowIndex].length,
5928
+ rowIndex: conflict.endRowIndex
5929
+ };
5930
+ const deleted = state.lines.slice(conflict.startRowIndex, conflict.endRowIndex + 1);
5931
+ const selections = new Uint32Array([conflict.startRowIndex, 0, conflict.startRowIndex, 0]);
5932
+ const result = await scheduleDocumentAndCursorsSelections(state, [{
5933
+ deleted,
5934
+ end,
5935
+ inserted,
5936
+ origin: Unknown$2,
5937
+ start
5938
+ }], selections);
5939
+ return {
5940
+ ...result,
5941
+ incrementalEdits: emptyIncrementalEdits
5942
+ };
5943
+ };
5944
+ const handleMergeConflictActionsMouseDown = state => state;
5945
+
5752
5946
  // @ts-ignore
5753
5947
  const getNewSelections$d = selections => {
5754
5948
  const newSelections = [];
@@ -6089,6 +6283,7 @@ const at = async (editor, eventX, eventY) => {
6089
6283
  lines,
6090
6284
  rowHeight,
6091
6285
  tabSize,
6286
+ viewLineIndices,
6092
6287
  x,
6093
6288
  y
6094
6289
  } = editor;
@@ -6099,7 +6294,7 @@ const at = async (editor, eventX, eventY) => {
6099
6294
  rowIndex: 0
6100
6295
  };
6101
6296
  }
6102
- const rowIndex = getDocumentRowForVisualRow(visualRowIndex, foldingRanges);
6297
+ const rowIndex = viewLineIndices ? getDocumentRowForVisualRow$1(visualRowIndex, viewLineIndices) : getDocumentRowForVisualRow(visualRowIndex, foldingRanges);
6103
6298
  const relativeX = eventX - x - gutterWidth + deltaX;
6104
6299
  const clampedRowIndex = clamp(rowIndex, 0, lines.length - 1);
6105
6300
  const line = lines[clampedRowIndex];
@@ -6934,6 +7129,7 @@ const getColorPickerBounds = editor => {
6934
7129
  height: editorHeight,
6935
7130
  rowHeight,
6936
7131
  selections,
7132
+ viewLineIndices,
6937
7133
  width: editorWidth,
6938
7134
  x: editorX,
6939
7135
  y: editorY
@@ -6945,7 +7141,7 @@ const getColorPickerBounds = editor => {
6945
7141
  const editorRight = editorX + editorWidth;
6946
7142
  const editorBottom = editorY + editorHeight;
6947
7143
  const cursorX = editorX + columnIndex * columnWidth - deltaX;
6948
- const visualRowIndex = getVisualRowForDocumentRow(rowIndex, foldingRanges);
7144
+ const visualRowIndex = viewLineIndices ? getVisualRowForDocumentRow$1(rowIndex, viewLineIndices) : getVisualRowForDocumentRow(rowIndex, foldingRanges);
6949
7145
  const lineTop = editorY + visualRowIndex * rowHeight - deltaY;
6950
7146
  const lineBottom = lineTop + rowHeight;
6951
7147
  const yAbove = lineTop - height;
@@ -12583,7 +12779,10 @@ const HandleScrollBarVerticalPointerUp = 32;
12583
12779
  const HandleWheel = 33;
12584
12780
  const HandleKeyUp = 34;
12585
12781
  const HandleLightBulbClick = 35;
12782
+ const HandleMergeConflictActionClick = 36;
12783
+ const HandleMergeConflictActionsMouseDown = 37;
12586
12784
 
12785
+ const Button$1 = 1;
12587
12786
  const Div = 4;
12588
12787
  const Input = 6;
12589
12788
  const Span = 8;
@@ -13697,6 +13896,7 @@ const kAutoClosingBrackets = 'editor.autoclosingBrackets';
13697
13896
  const kFontWeight = 'editor.fontWeight';
13698
13897
  const kHover = 'editor.hover';
13699
13898
  const kMinimapEnabled = 'editor.minimap.enabled';
13899
+ const kMergeConflictActions = 'editor.mergeConflictActions';
13700
13900
  const kBreadcrumbsEnabled = 'breadcrumbs.enabled';
13701
13901
  const kDragAndDropEnabled = 'editor.dragAndDrop';
13702
13902
  const getDragAndDropEnabled = async () => {
@@ -13756,12 +13956,15 @@ const getFontWeight = async () => {
13756
13956
  const getMinimapEnabled = async () => {
13757
13957
  return (await get$3(kMinimapEnabled)) ?? false;
13758
13958
  };
13959
+ const getMergeConflictActionsEnabled = async () => {
13960
+ return (await get$3(kMergeConflictActions)) ?? false;
13961
+ };
13759
13962
  const getBreadcrumbsEnabled = async () => {
13760
13963
  return (await get$3(kBreadcrumbsEnabled)) ?? false;
13761
13964
  };
13762
13965
 
13763
13966
  const getEditorPreferences = async () => {
13764
- const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getBreadcrumbsEnabled(), getInsertSpaces(), getDragAndDropEnabled()]);
13967
+ const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), getBreadcrumbsEnabled(), getInsertSpaces(), getDragAndDropEnabled()]);
13765
13968
  return {
13766
13969
  breadcrumbsEnabled,
13767
13970
  completionTriggerCharacters,
@@ -13779,6 +13982,7 @@ const getEditorPreferences = async () => {
13779
13982
  isQuickSuggestionsEnabled: isQuickSuggestionsEnabled$1,
13780
13983
  letterSpacing,
13781
13984
  lineNumbers,
13985
+ mergeConflictActionsEnabled,
13782
13986
  minimapEnabled,
13783
13987
  rowHeight,
13784
13988
  tabSize
@@ -14120,6 +14324,7 @@ const loadContent = async (state, savedState) => {
14120
14324
  isQuickSuggestionsEnabled,
14121
14325
  letterSpacing,
14122
14326
  lineNumbers,
14327
+ mergeConflictActionsEnabled,
14123
14328
  minimapEnabled,
14124
14329
  rowHeight,
14125
14330
  tabSize
@@ -14155,6 +14360,7 @@ const loadContent = async (state, savedState) => {
14155
14360
  letterSpacing,
14156
14361
  lineNumbers,
14157
14362
  loadError: '',
14363
+ mergeConflictActionsEnabled,
14158
14364
  minimapEnabled,
14159
14365
  rowHeight,
14160
14366
  tabSize,
@@ -14366,6 +14572,34 @@ ${editorSelector} .EditorRow {
14366
14572
  height: var(--EditorRowHeight);
14367
14573
  line-height: var(--EditorRowHeight);
14368
14574
  }
14575
+ ${editorSelector} .MergeConflictActions,
14576
+ ${editorSelector} .MergeConflictActionsGutter {
14577
+ box-sizing: border-box;
14578
+ height: var(--EditorRowHeight);
14579
+ line-height: var(--EditorRowHeight);
14580
+ }
14581
+ ${editorSelector} .MergeConflictActions {
14582
+ align-items: center;
14583
+ display: flex;
14584
+ gap: 12px;
14585
+ padding-left: 4px;
14586
+ user-select: none;
14587
+ }
14588
+ ${editorSelector} .MergeConflictAction {
14589
+ appearance: none;
14590
+ background: none;
14591
+ border: 0;
14592
+ color: var(--TextLinkForeground, #3794ff);
14593
+ cursor: pointer;
14594
+ font: inherit;
14595
+ padding: 0;
14596
+ }
14597
+ ${editorSelector} .MergeConflictAction:hover,
14598
+ ${editorSelector} .MergeConflictAction:focus-visible {
14599
+ color: var(--TextLinkActiveForeground, #4daafc);
14600
+ outline: none;
14601
+ text-decoration: underline;
14602
+ }
14369
14603
  ${editorSelector} .EditorLineDecoration {
14370
14604
  color: var(--EditorInlineBlameForeground, rgba(255, 255, 255, 0.5));
14371
14605
  font-style: italic;
@@ -14928,15 +15162,57 @@ const editorLineDecorationNode = {
14928
15162
  className: EditorLineDecoration,
14929
15163
  type: Span
14930
15164
  };
14931
- const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = []) => {
15165
+ const mergeConflictActions = [{
15166
+ action: 'current',
15167
+ label: 'Accept Current Change'
15168
+ }, {
15169
+ action: 'incoming',
15170
+ label: 'Accept Incoming Change'
15171
+ }, {
15172
+ action: 'both',
15173
+ label: 'Accept Both Changes'
15174
+ }];
15175
+ const addMergeConflictActions = (dom, rowIndex) => {
15176
+ dom.push({
15177
+ childCount: mergeConflictActions.length,
15178
+ className: 'MergeConflictActions',
15179
+ 'data-rowIndex': rowIndex,
15180
+ onMouseDown: HandleMergeConflictActionsMouseDown,
15181
+ type: Div
15182
+ });
15183
+ for (const {
15184
+ action,
15185
+ label
15186
+ } of mergeConflictActions) {
15187
+ dom.push({
15188
+ ariaLabel: `${label} at line ${rowIndex + 1}`,
15189
+ childCount: 1,
15190
+ className: 'MergeConflictAction',
15191
+ 'data-action': action,
15192
+ 'data-rowIndex': rowIndex,
15193
+ onClick: HandleMergeConflictActionClick,
15194
+ title: label,
15195
+ type: Button$1
15196
+ }, text(label));
15197
+ }
15198
+ };
15199
+ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = []) => {
14932
15200
  const dom = [];
14933
- for (let i = 0; i < textInfos.length; i++) {
14934
- const textInfo = textInfos[i];
14935
- const difference = differences[i];
14936
- const rowIndex = visibleLineIndices[i] ?? i;
15201
+ const actualViewRows = visibleViewLineIndices.length === 0 ? Array.from({
15202
+ length: textInfos.length
15203
+ }, (_, index) => visibleLineIndices[index] ?? index) : visibleViewLineIndices;
15204
+ let textInfoIndex = 0;
15205
+ for (const viewRow of actualViewRows) {
15206
+ if (isMergeConflictActionsRow(viewRow)) {
15207
+ addMergeConflictActions(dom, getMergeConflictRowIndex(viewRow));
15208
+ continue;
15209
+ }
15210
+ const textInfo = textInfos[textInfoIndex];
15211
+ const difference = differences[textInfoIndex];
15212
+ const rowIndex = viewRow;
14937
15213
  const rowDecorations = endOfLineDecorations.filter(decoration => decoration.rowIndex === rowIndex);
14938
15214
  let className = EditorRow;
14939
- if (i === highlightedLine) {
15215
+ if (rowIndex === highlightedLine) {
14940
15216
  className = mergeClassNames(className, EditorRowHighlighted);
14941
15217
  }
14942
15218
  dom.push({
@@ -14957,14 +15233,15 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
14957
15233
  for (const decoration of rowDecorations) {
14958
15234
  dom.push(editorLineDecorationNode, text(decoration.text));
14959
15235
  }
15236
+ textInfoIndex++;
14960
15237
  }
14961
15238
  return dom;
14962
15239
  };
14963
15240
 
14964
- const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = []) => {
14965
- const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations);
15241
+ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = []) => {
15242
+ const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices);
14966
15243
  return [{
14967
- childCount: textInfos.length,
15244
+ childCount: visibleViewLineIndices.length || textInfos.length,
14968
15245
  className: 'EditorRows',
14969
15246
  onMouseDown: HandleMouseDown,
14970
15247
  onPointerDown: HandlePointerDown,
@@ -15007,8 +15284,8 @@ const editorLayersNode = {
15007
15284
  className: 'EditorLayers',
15008
15285
  type: Div
15009
15286
  };
15010
- const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true) => {
15011
- return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
15287
+ const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = []) => {
15288
+ return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
15012
15289
  };
15013
15290
 
15014
15291
  const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
@@ -15076,20 +15353,24 @@ const getEditorContentVirtualDom = ({
15076
15353
  scrollBarDiagnostics = [],
15077
15354
  selectionInfos = [],
15078
15355
  textInfos,
15079
- visibleLineIndices = []
15356
+ visibleLineIndices = [],
15357
+ visibleViewLineIndices = []
15080
15358
  }) => {
15081
- return [editorContentNode, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
15359
+ return [editorContentNode, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
15082
15360
  };
15083
15361
 
15084
15362
  const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
15085
15363
  const isBreakpoint = typeof gutterInfo === 'object' && gutterInfo.isBreakpoint;
15086
15364
  const isLightBulb = typeof gutterInfo === 'object' && gutterInfo.isLightBulb;
15365
+ const isMergeConflictActions = typeof gutterInfo === 'object' && gutterInfo.isMergeConflictActions;
15087
15366
  const lineNumber = typeof gutterInfo === 'object' ? gutterInfo.lineNumber : gutterInfo;
15088
15367
  const gutterDecorations = typeof gutterInfo === 'object' ? gutterInfo.gutterDecorations || [] : [];
15089
15368
  const showLineNumber = typeof gutterInfo !== 'object' || gutterInfo.showLineNumber !== false;
15090
15369
  const label = isLightBulb ? `Show Code Actions on line ${lineNumber}` : `Breakpoint on line ${lineNumber}`;
15091
15370
  let className = lineNumber === activeLineNumber ? 'LineNumber LineNumberActive' : 'LineNumber';
15092
- if (isLightBulb) {
15371
+ if (isMergeConflictActions) {
15372
+ className += ' MergeConflictActionsGutter';
15373
+ } else if (isLightBulb) {
15093
15374
  className += ' LineNumberLightBulb MaskIconLightBulb';
15094
15375
  } else if (isBreakpoint) {
15095
15376
  className += ' LineNumberBreakpoint';
@@ -15115,7 +15396,7 @@ const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
15115
15396
  className: mergeClassNames('EditorGutterDecoration', `EditorGutterDecoration${decoration.type[0].toUpperCase()}${decoration.type.slice(1)}`),
15116
15397
  title: `${decoration.type[0].toUpperCase()}${decoration.type.slice(1)} line ${lineNumber}`,
15117
15398
  type: Span
15118
- })), text(isLightBulb ? '' : isBreakpoint ? '●' : showLineNumber ? lineNumber : '')];
15399
+ })), text(isMergeConflictActions || isLightBulb ? '' : isBreakpoint ? '●' : showLineNumber ? lineNumber : '')];
15119
15400
  };
15120
15401
  const getEditorGutterVirtualDom$1 = (gutterInfos, activeLineNumber = -1) => {
15121
15402
  const dom = gutterInfos.flatMap(gutterInfo => getGutterInfoVirtualDom(gutterInfo, activeLineNumber));
@@ -15137,6 +15418,14 @@ const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true,
15137
15418
  length: maxLineY - minLineY
15138
15419
  }, (_, index) => minLineY + index);
15139
15420
  for (const rowIndex of rows) {
15421
+ if (rowIndex < 0) {
15422
+ gutterInfos.push({
15423
+ isMergeConflictActions: true,
15424
+ lineNumber: 0,
15425
+ showLineNumber: false
15426
+ });
15427
+ continue;
15428
+ }
15140
15429
  const lineNumber = rowIndex + 1;
15141
15430
  const isBreakpoint = breakPoints.includes(rowIndex);
15142
15431
  const isLightBulb = rowIndex === lightBulbRowIndex;
@@ -15228,6 +15517,7 @@ const getEditorVirtualDom = ({
15228
15517
  uid,
15229
15518
  uri = '',
15230
15519
  visibleLineIndices,
15520
+ visibleViewLineIndices = [],
15231
15521
  workspaceUri = ''
15232
15522
  }) => {
15233
15523
  if (loadError) {
@@ -15239,7 +15529,8 @@ const getEditorVirtualDom = ({
15239
15529
  type: Div
15240
15530
  }, textEditorErrorIconNode, textEditorErrorMessageNode, text(loadError)];
15241
15531
  }
15242
- const visibleGutterInfos = breakPoints.length > 0 || gutterDecorations.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex, gutterDecorations) : gutterInfos;
15532
+ const gutterLineIndices = visibleViewLineIndices.length > 0 ? visibleViewLineIndices : visibleLineIndices;
15533
+ const visibleGutterInfos = breakPoints.length > 0 || gutterDecorations.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, gutterLineIndices, lightBulbRowIndex, gutterDecorations) : gutterInfos;
15243
15534
  const showGutter = lineNumbers || breakPoints.length > 0 || lightBulbRowIndex >= 0 || gutterDecorations.length > 0;
15244
15535
  const primaryCursorRowIndex = getPrimaryCursorRowIndex(selections, primarySelectionIndex);
15245
15536
  const activeLineNumber = highlightActiveLineNumber ? primaryCursorRowIndex + 1 : -1;
@@ -15273,17 +15564,18 @@ const getEditorVirtualDom = ({
15273
15564
  scrollBarDiagnostics,
15274
15565
  selectionInfos,
15275
15566
  textInfos,
15276
- visibleLineIndices: visibleLineIndices || []
15567
+ visibleLineIndices: visibleLineIndices || [],
15568
+ visibleViewLineIndices
15277
15569
  }), ...minimapDom];
15278
15570
  };
15279
15571
 
15280
15572
  const getScrollBarDiagnostics = (editor, diagnostics) => {
15281
15573
  const height = editor.height || 0;
15282
- const lineCount = Math.max(editor.lines?.length || 0, 1);
15574
+ const lineCount = Math.max(editor.viewLineIndices?.length || editor.lines?.length || 0, 1);
15283
15575
  const markerHeight = 3;
15284
15576
  const scrollBarDecorations = Array.from(diagnostics, diagnostic => ({
15285
15577
  height: markerHeight,
15286
- top: Math.min(Math.round(diagnostic.rowIndex / lineCount * height), Math.max(height - markerHeight, 0)),
15578
+ top: Math.min(Math.round((editor.viewLineIndices ? getVisualRowForDocumentRow$1(diagnostic.rowIndex, editor.viewLineIndices) : diagnostic.rowIndex) / lineCount * height), Math.max(height - markerHeight, 0)),
15287
15579
  type: diagnostic.type
15288
15580
  }));
15289
15581
  return scrollBarDecorations;
@@ -15313,8 +15605,16 @@ const getDom = state => {
15313
15605
  scrollBarDiagnostics: getScrollBarDiagnostics(state, diagnostics)
15314
15606
  });
15315
15607
  };
15608
+ const mergeConflictsEqual = (oldState, newState) => {
15609
+ const oldConflicts = oldState.mergeConflicts || [];
15610
+ const newConflicts = newState.mergeConflicts || [];
15611
+ return oldConflicts.length === newConflicts.length && oldConflicts.every((conflict, index) => {
15612
+ const other = newConflicts[index];
15613
+ return conflict.startRowIndex === other.startRowIndex && conflict.endRowIndex === other.endRowIndex;
15614
+ });
15615
+ };
15316
15616
  const renderIncremental = (oldState, newState) => {
15317
- const oldDom = oldState.initial ? getDom(oldState) : get(newState.uid) || getDom(oldState);
15617
+ const oldDom = oldState.initial || !mergeConflictsEqual(oldState, newState) ? getDom(oldState) : get(newState.uid) || getDom(oldState);
15318
15618
  const newDom = getDom(newState);
15319
15619
  const patches = diffTree(oldDom, newDom);
15320
15620
  if (patches.length === 0) {
@@ -15459,13 +15759,13 @@ const renderLines = {
15459
15759
  newState.differences = differences;
15460
15760
  const {
15461
15761
  highlightedLine,
15462
- visibleLineIndices
15762
+ visibleLineIndices,
15763
+ visibleViewLineIndices
15463
15764
  } = newState;
15464
- const relativeLine = visibleLineIndices.indexOf(highlightedLine);
15465
- const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine, visibleLineIndices, endOfLineDecorations);
15765
+ const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices);
15466
15766
  return [/* method */'setText', dom];
15467
15767
  },
15468
- isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
15768
+ isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
15469
15769
  };
15470
15770
  const renderSelections = {
15471
15771
  apply: (oldState, newState) => {
@@ -15516,18 +15816,20 @@ const renderGutterInfo = {
15516
15816
  minLineY,
15517
15817
  primarySelectionIndex,
15518
15818
  selections,
15519
- visibleLineIndices
15819
+ visibleLineIndices,
15820
+ visibleViewLineIndices = []
15520
15821
  } = newState;
15521
15822
  if (!lineNumbers && breakPoints.length === 0 && lightBulbRowIndex === -1 && gutterDecorations.length === 0) {
15522
15823
  return ['renderGutter', []];
15523
15824
  }
15524
- const gutterInfos = getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices, lightBulbRowIndex, gutterDecorations);
15825
+ const gutterLineIndices = visibleViewLineIndices.length > 0 ? visibleViewLineIndices : visibleLineIndices;
15826
+ const gutterInfos = getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, gutterLineIndices, lightBulbRowIndex, gutterDecorations);
15525
15827
  const primaryCursorRowIndex = getPrimaryCursorRowIndex(selections, primarySelectionIndex);
15526
15828
  const activeLineNumber = highlightActiveLineNumber ? primaryCursorRowIndex + 1 : -1;
15527
15829
  const dom = getEditorGutterVirtualDom$1(gutterInfos, activeLineNumber);
15528
15830
  return ['renderGutter', dom];
15529
15831
  },
15530
- isEqual: (oldState, newState) => oldState.breakPoints === newState.breakPoints && oldState.gutterDecorations === newState.gutterDecorations && oldState.lightBulbRowIndex === newState.lightBulbRowIndex && oldState.foldingRanges === newState.foldingRanges && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.lineNumbers === newState.lineNumbers && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && (!newState.highlightActiveLineNumber || getPrimaryCursorRowIndex(oldState.selections, oldState.primarySelectionIndex) === getPrimaryCursorRowIndex(newState.selections, newState.primarySelectionIndex))
15832
+ isEqual: (oldState, newState) => oldState.breakPoints === newState.breakPoints && oldState.gutterDecorations === newState.gutterDecorations && oldState.lightBulbRowIndex === newState.lightBulbRowIndex && oldState.foldingRanges === newState.foldingRanges && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.lineNumbers === newState.lineNumbers && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && (!newState.highlightActiveLineNumber || getPrimaryCursorRowIndex(oldState.selections, oldState.primarySelectionIndex) === getPrimaryCursorRowIndex(newState.selections, newState.primarySelectionIndex))
15531
15833
  };
15532
15834
  const renderWidgets = {
15533
15835
  apply: renderWidgets$1,
@@ -15566,6 +15868,16 @@ const renderEventListeners = () => {
15566
15868
  name: HandleLightBulbClick,
15567
15869
  params: ['showSourceActions3'],
15568
15870
  preventDefault: true
15871
+ }, {
15872
+ name: HandleMergeConflictActionClick,
15873
+ params: ['acceptMergeConflict', 'event.target.dataset.action', 'event.target.dataset.rowIndex'],
15874
+ preventDefault: true,
15875
+ stopPropagation: true
15876
+ }, {
15877
+ name: HandleMergeConflictActionsMouseDown,
15878
+ params: ['handleMergeConflictActionsMouseDown'],
15879
+ preventDefault: true,
15880
+ stopPropagation: true
15569
15881
  }, {
15570
15882
  name: HandleFocus,
15571
15883
  params: ['handleFocus']
@@ -15618,7 +15930,7 @@ const renderEventListeners = () => {
15618
15930
  passive: true
15619
15931
  }, {
15620
15932
  name: HandleContextMenu,
15621
- params: ['handleContextMenu', Button$1, ClientX, ClientY],
15933
+ params: ['handleContextMenu', Button$2, ClientX, ClientY],
15622
15934
  preventDefault: true
15623
15935
  }, {
15624
15936
  name: HandleScrollBarVerticalPointerDown,
@@ -15973,6 +16285,7 @@ const commandMap = {
15973
16285
  'ActivateByEvent.activateByEvent': activateByEvent,
15974
16286
  'CodeGenerator.accept': codeGeneratorAccept,
15975
16287
  'ColorPicker.loadContent': loadContent$3,
16288
+ 'Editor.acceptMergeConflict': wrapCommand(acceptMergeConflict),
15976
16289
  'Editor.addCursorAbove': wrapCommand(addCursorAbove),
15977
16290
  'Editor.addCursorBelow': wrapCommand(addCursorBelow),
15978
16291
  'Editor.applyDocumentEdits': wrapCommand(applyDocumentEdits$1),
@@ -16074,6 +16387,7 @@ const commandMap = {
16074
16387
  'Editor.handleDoubleClick': wrapCommand(handleDoubleClick),
16075
16388
  'Editor.handleFocus': wrapCommand(handleFocus$1),
16076
16389
  'Editor.handleKeyUp': wrapCommand(handleKeyUp, true),
16390
+ 'Editor.handleMergeConflictActionsMouseDown': wrapCommand(handleMergeConflictActionsMouseDown),
16077
16391
  'Editor.handleMouseDown': wrapCommand(handleMouseDown),
16078
16392
  'Editor.handleMouseMove': wrapCommand(handleMouseMove),
16079
16393
  'Editor.handleMouseMoveWithAltKey': wrapCommand(handleMouseMoveWithAltKey),
@@ -53,6 +53,14 @@
53
53
  "type": 1,
54
54
  "value": "on"
55
55
  },
56
+ {
57
+ "category": "text-editor",
58
+ "description": "Controls whether actions for accepting merge conflict changes are shown in the editor",
59
+ "heading": "Merge Conflict Actions",
60
+ "id": "editor.mergeConflictActions",
61
+ "type": 3,
62
+ "value": false
63
+ },
56
64
  {
57
65
  "category": "text-editor",
58
66
  "description": "Controls whether the primary cursor line number is highlighted",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.49.0",
3
+ "version": "19.50.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"