@lvce-editor/editor-worker 19.30.12 → 19.31.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 +309 -26
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1393,6 +1393,7 @@ const KeyC = 31;
|
|
|
1393
1393
|
const KeyD = 32;
|
|
1394
1394
|
const KeyF = 34;
|
|
1395
1395
|
const KeyH = 36;
|
|
1396
|
+
const KeyI = 37;
|
|
1396
1397
|
const KeyJ = 38;
|
|
1397
1398
|
const KeyK = 39;
|
|
1398
1399
|
const KeyL = 40;
|
|
@@ -3259,7 +3260,7 @@ const getEnabled = () => {
|
|
|
3259
3260
|
};
|
|
3260
3261
|
|
|
3261
3262
|
// TODO this should be in a separate scrolling module
|
|
3262
|
-
const setDeltaY$
|
|
3263
|
+
const setDeltaY$1 = async (state, value) => {
|
|
3263
3264
|
object(state);
|
|
3264
3265
|
number(value);
|
|
3265
3266
|
const {
|
|
@@ -4001,11 +4002,11 @@ const applyEdit$1 = (editor, changes) => {
|
|
|
4001
4002
|
};
|
|
4002
4003
|
|
|
4003
4004
|
// TODO
|
|
4004
|
-
const setDeltaYFixedValue
|
|
4005
|
-
return setDeltaY$
|
|
4005
|
+
const setDeltaYFixedValue = (editor, value) => {
|
|
4006
|
+
return setDeltaY$1(editor, value);
|
|
4006
4007
|
};
|
|
4007
|
-
const setDeltaY
|
|
4008
|
-
return setDeltaYFixedValue
|
|
4008
|
+
const setDeltaY = (editor, value) => {
|
|
4009
|
+
return setDeltaYFixedValue(editor, editor.deltaY + value);
|
|
4009
4010
|
};
|
|
4010
4011
|
const isAutoClosingChange = change => {
|
|
4011
4012
|
return change.origin === EditorTypeWithAutoClosing;
|
|
@@ -4864,9 +4865,9 @@ const createEditor = async ({
|
|
|
4864
4865
|
if (lineToReveal && columnToReveal) {
|
|
4865
4866
|
const delta = lineToReveal * rowHeight;
|
|
4866
4867
|
// TODO scroll to this line
|
|
4867
|
-
newEditor3 = await setDeltaY$
|
|
4868
|
+
newEditor3 = await setDeltaY$1(newEditor2, delta);
|
|
4868
4869
|
} else {
|
|
4869
|
-
newEditor3 = await setDeltaY$
|
|
4870
|
+
newEditor3 = await setDeltaY$1(newEditor2, 0);
|
|
4870
4871
|
}
|
|
4871
4872
|
|
|
4872
4873
|
// Detect links and initialize decorations
|
|
@@ -5160,7 +5161,7 @@ const disposeEditor = async editorUid => {
|
|
|
5160
5161
|
};
|
|
5161
5162
|
|
|
5162
5163
|
// @ts-ignore
|
|
5163
|
-
const getNewSelections$
|
|
5164
|
+
const getNewSelections$d = selections => {
|
|
5164
5165
|
const newSelections = [];
|
|
5165
5166
|
for (let i = 0; i < selections.length; i += 4) {
|
|
5166
5167
|
const startRowIndex = selections[i];
|
|
@@ -5180,7 +5181,7 @@ const addCursorAbove = editor => {
|
|
|
5180
5181
|
const {
|
|
5181
5182
|
selections
|
|
5182
5183
|
} = editor;
|
|
5183
|
-
const newSelections = getNewSelections$
|
|
5184
|
+
const newSelections = getNewSelections$d(selections);
|
|
5184
5185
|
return {
|
|
5185
5186
|
...editor,
|
|
5186
5187
|
selections: newSelections
|
|
@@ -5188,7 +5189,7 @@ const addCursorAbove = editor => {
|
|
|
5188
5189
|
};
|
|
5189
5190
|
|
|
5190
5191
|
// @ts-ignore
|
|
5191
|
-
const getNewSelections$
|
|
5192
|
+
const getNewSelections$c = (selections, linesLength) => {
|
|
5192
5193
|
const newSelections = [];
|
|
5193
5194
|
for (let i = 0; i < selections.length; i += 4) {
|
|
5194
5195
|
const startRowIndex = selections[i];
|
|
@@ -5209,7 +5210,7 @@ const addCursorBelow = editor => {
|
|
|
5209
5210
|
lines,
|
|
5210
5211
|
selections
|
|
5211
5212
|
} = editor;
|
|
5212
|
-
const newSelections = getNewSelections$
|
|
5213
|
+
const newSelections = getNewSelections$c(selections, lines.length);
|
|
5213
5214
|
return {
|
|
5214
5215
|
...editor,
|
|
5215
5216
|
selections: newSelections
|
|
@@ -5897,6 +5898,251 @@ const cancelSelection = editor => {
|
|
|
5897
5898
|
return scheduleSelections(editor, newSelections);
|
|
5898
5899
|
};
|
|
5899
5900
|
|
|
5901
|
+
const colorPattern$1 = /#[\dA-Fa-f]+/g;
|
|
5902
|
+
const numberPattern = /(?<![\w.#])[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?(?![\d.])/g;
|
|
5903
|
+
const validColorLengths = new Set([4, 5, 7, 9]);
|
|
5904
|
+
const isColor = value => {
|
|
5905
|
+
return validColorLengths.has(value.length) && /^#[\dA-Fa-f]+$/.test(value);
|
|
5906
|
+
};
|
|
5907
|
+
const isNumber = value => {
|
|
5908
|
+
return /^[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?$/.test(value);
|
|
5909
|
+
};
|
|
5910
|
+
const adjustNumber = (value, delta) => {
|
|
5911
|
+
const match = /^([+-]?)(?:(\d+)(?:\.(\d*))?|\.(\d+))([eE][+-]?\d+)?$/.exec(value);
|
|
5912
|
+
if (!match) {
|
|
5913
|
+
return value;
|
|
5914
|
+
}
|
|
5915
|
+
const [, originalSign, integerPart = '', fractionAfterInteger, fractionWithoutInteger, exponent = ''] = match;
|
|
5916
|
+
const fraction = fractionAfterInteger ?? fractionWithoutInteger ?? '';
|
|
5917
|
+
const mantissaEnd = exponent ? value.length - exponent.length : value.length;
|
|
5918
|
+
const hadDecimalPoint = value.slice(0, mantissaEnd).includes('.');
|
|
5919
|
+
const scale = fraction.length;
|
|
5920
|
+
const unsignedUnits = BigInt(`${integerPart || '0'}${fraction}`);
|
|
5921
|
+
const signedUnits = originalSign === '-' ? -unsignedUnits : unsignedUnits;
|
|
5922
|
+
const nextUnits = signedUnits + BigInt(delta);
|
|
5923
|
+
const isNegative = nextUnits < 0;
|
|
5924
|
+
const absoluteUnits = isNegative ? -nextUnits : nextUnits;
|
|
5925
|
+
const minimumIntegerLength = Math.max(integerPart.length, 1);
|
|
5926
|
+
const digits = absoluteUnits.toString().padStart(scale + minimumIntegerLength, '0');
|
|
5927
|
+
const resultInteger = scale === 0 ? digits : digits.slice(0, -scale);
|
|
5928
|
+
const resultFraction = scale === 0 ? '' : digits.slice(-scale);
|
|
5929
|
+
const omitLeadingZero = integerPart === '' && resultInteger === '0';
|
|
5930
|
+
const mantissa = `${omitLeadingZero ? '' : resultInteger}${hadDecimalPoint ? '.' : ''}${resultFraction}`;
|
|
5931
|
+
const sign = isNegative ? '-' : originalSign === '+' ? '+' : '';
|
|
5932
|
+
return `${sign}${mantissa}${exponent}`;
|
|
5933
|
+
};
|
|
5934
|
+
const adjustColorComponent = (digits, componentIndex, componentWidth, delta, uppercase) => {
|
|
5935
|
+
const start = componentIndex * componentWidth;
|
|
5936
|
+
const value = Number.parseInt(digits.slice(start, start + componentWidth), 16);
|
|
5937
|
+
const maximum = componentWidth === 1 ? 0xf : 0xff;
|
|
5938
|
+
const nextValue = Math.max(0, Math.min(maximum, value + delta));
|
|
5939
|
+
const replacement = nextValue.toString(16).padStart(componentWidth, '0');
|
|
5940
|
+
return `${digits.slice(0, start)}${uppercase ? replacement.toUpperCase() : replacement}${digits.slice(start + componentWidth)}`;
|
|
5941
|
+
};
|
|
5942
|
+
const adjustColor = (value, delta, activeOffset) => {
|
|
5943
|
+
const digits = value.slice(1);
|
|
5944
|
+
const componentWidth = digits.length <= 4 ? 1 : 2;
|
|
5945
|
+
const componentCount = digits.length / componentWidth;
|
|
5946
|
+
const uppercase = /[A-F]/.test(digits) && !/[a-f]/.test(digits);
|
|
5947
|
+
if (activeOffset !== undefined && activeOffset > 0) {
|
|
5948
|
+
const digitOffset = Math.min(activeOffset - 1, digits.length - 1);
|
|
5949
|
+
const componentIndex = Math.floor(digitOffset / componentWidth);
|
|
5950
|
+
return `#${adjustColorComponent(digits, componentIndex, componentWidth, delta, uppercase)}`;
|
|
5951
|
+
}
|
|
5952
|
+
let adjusted = digits;
|
|
5953
|
+
for (let componentIndex = 0; componentIndex < Math.min(componentCount, 3); componentIndex++) {
|
|
5954
|
+
adjusted = adjustColorComponent(adjusted, componentIndex, componentWidth, delta, uppercase);
|
|
5955
|
+
}
|
|
5956
|
+
return `#${adjusted}`;
|
|
5957
|
+
};
|
|
5958
|
+
const changeValue = (value, delta, activeOffset = undefined) => {
|
|
5959
|
+
if (isColor(value)) {
|
|
5960
|
+
return adjustColor(value, delta, activeOffset);
|
|
5961
|
+
}
|
|
5962
|
+
if (isNumber(value)) {
|
|
5963
|
+
return adjustNumber(value, delta);
|
|
5964
|
+
}
|
|
5965
|
+
return value;
|
|
5966
|
+
};
|
|
5967
|
+
const findMatchAt = (line, columnIndex, pattern, predicate) => {
|
|
5968
|
+
pattern.lastIndex = 0;
|
|
5969
|
+
for (const match of line.matchAll(pattern)) {
|
|
5970
|
+
const value = match[0];
|
|
5971
|
+
const start = match.index;
|
|
5972
|
+
const end = start + value.length;
|
|
5973
|
+
if (predicate(value) && columnIndex >= start && columnIndex <= end) {
|
|
5974
|
+
return {
|
|
5975
|
+
end,
|
|
5976
|
+
start,
|
|
5977
|
+
value
|
|
5978
|
+
};
|
|
5979
|
+
}
|
|
5980
|
+
}
|
|
5981
|
+
return undefined;
|
|
5982
|
+
};
|
|
5983
|
+
const findValueAt = (line, columnIndex) => {
|
|
5984
|
+
return findMatchAt(line, columnIndex, colorPattern$1, isColor) ?? findMatchAt(line, columnIndex, numberPattern, isNumber);
|
|
5985
|
+
};
|
|
5986
|
+
const getSelectionTarget = (editor, index) => {
|
|
5987
|
+
const selectionStartRow = editor.selections[index];
|
|
5988
|
+
const selectionStartColumn = editor.selections[index + 1];
|
|
5989
|
+
const selectionEndRow = editor.selections[index + 2];
|
|
5990
|
+
if (selectionStartRow !== selectionEndRow) {
|
|
5991
|
+
return undefined;
|
|
5992
|
+
}
|
|
5993
|
+
const selectionEndColumn = editor.selections[index + 3];
|
|
5994
|
+
const rowIndex = selectionStartRow;
|
|
5995
|
+
const line = editor.lines[rowIndex];
|
|
5996
|
+
const start = Math.min(selectionStartColumn, selectionEndColumn);
|
|
5997
|
+
const end = Math.max(selectionStartColumn, selectionEndColumn);
|
|
5998
|
+
if (start !== end) {
|
|
5999
|
+
const value = line.slice(start, end);
|
|
6000
|
+
if (!isColor(value) && !isNumber(value)) {
|
|
6001
|
+
return undefined;
|
|
6002
|
+
}
|
|
6003
|
+
return {
|
|
6004
|
+
activeOffset: undefined,
|
|
6005
|
+
end,
|
|
6006
|
+
index,
|
|
6007
|
+
rowIndex,
|
|
6008
|
+
selectionEnd: selectionEndColumn,
|
|
6009
|
+
selectionStart: selectionStartColumn,
|
|
6010
|
+
start,
|
|
6011
|
+
value
|
|
6012
|
+
};
|
|
6013
|
+
}
|
|
6014
|
+
const range = findValueAt(line, selectionEndColumn);
|
|
6015
|
+
if (!range) {
|
|
6016
|
+
return undefined;
|
|
6017
|
+
}
|
|
6018
|
+
return {
|
|
6019
|
+
...range,
|
|
6020
|
+
activeOffset: selectionEndColumn - range.start,
|
|
6021
|
+
index,
|
|
6022
|
+
rowIndex,
|
|
6023
|
+
selectionEnd: selectionEndColumn,
|
|
6024
|
+
selectionStart: selectionStartColumn
|
|
6025
|
+
};
|
|
6026
|
+
};
|
|
6027
|
+
const getTargets = editor => {
|
|
6028
|
+
const targets = [];
|
|
6029
|
+
for (let index = 0; index < editor.selections.length; index += 4) {
|
|
6030
|
+
const target = getSelectionTarget(editor, index);
|
|
6031
|
+
if (target) {
|
|
6032
|
+
targets.push(target);
|
|
6033
|
+
}
|
|
6034
|
+
}
|
|
6035
|
+
return targets;
|
|
6036
|
+
};
|
|
6037
|
+
const getUniqueTargets = targets => {
|
|
6038
|
+
const seen = new Set();
|
|
6039
|
+
return targets.filter(target => {
|
|
6040
|
+
const key = `${target.rowIndex}:${target.start}:${target.end}`;
|
|
6041
|
+
if (seen.has(key)) {
|
|
6042
|
+
return false;
|
|
6043
|
+
}
|
|
6044
|
+
seen.add(key);
|
|
6045
|
+
return true;
|
|
6046
|
+
}).toSorted((a, b) => a.rowIndex - b.rowIndex || a.start - b.start);
|
|
6047
|
+
};
|
|
6048
|
+
const getColumnDeltaBefore = (targets, replacements, rowIndex, column) => {
|
|
6049
|
+
let delta = 0;
|
|
6050
|
+
for (const target of targets) {
|
|
6051
|
+
if (target.rowIndex !== rowIndex || target.end > column) {
|
|
6052
|
+
continue;
|
|
6053
|
+
}
|
|
6054
|
+
delta += replacements.get(target).length - target.value.length;
|
|
6055
|
+
}
|
|
6056
|
+
return delta;
|
|
6057
|
+
};
|
|
6058
|
+
const mapColumn = (targets, replacements, rowIndex, column) => {
|
|
6059
|
+
for (const target of targets) {
|
|
6060
|
+
if (target.rowIndex === rowIndex && column > target.start && column < target.end) {
|
|
6061
|
+
const replacement = replacements.get(target);
|
|
6062
|
+
return target.start + getColumnDeltaBefore(targets, replacements, rowIndex, target.start) + Math.min(column - target.start, replacement.length);
|
|
6063
|
+
}
|
|
6064
|
+
}
|
|
6065
|
+
return column + getColumnDeltaBefore(targets, replacements, rowIndex, column);
|
|
6066
|
+
};
|
|
6067
|
+
const getNewSelections$b = (editor, targets, uniqueTargets, replacements) => {
|
|
6068
|
+
const newSelections = new Uint32Array(editor.selections);
|
|
6069
|
+
const targetByIndex = new Map(targets.map(target => [target.index, target]));
|
|
6070
|
+
for (let index = 0; index < editor.selections.length; index += 4) {
|
|
6071
|
+
const startRow = editor.selections[index];
|
|
6072
|
+
const startColumn = editor.selections[index + 1];
|
|
6073
|
+
const endRow = editor.selections[index + 2];
|
|
6074
|
+
const endColumn = editor.selections[index + 3];
|
|
6075
|
+
const target = targetByIndex.get(index);
|
|
6076
|
+
if (!target) {
|
|
6077
|
+
newSelections[index + 1] = mapColumn(uniqueTargets, replacements, startRow, startColumn);
|
|
6078
|
+
newSelections[index + 3] = mapColumn(uniqueTargets, replacements, endRow, endColumn);
|
|
6079
|
+
continue;
|
|
6080
|
+
}
|
|
6081
|
+
const matchingTarget = uniqueTargets.find(candidate => candidate.rowIndex === target.rowIndex && candidate.start === target.start && candidate.end === target.end);
|
|
6082
|
+
const replacement = replacements.get(matchingTarget);
|
|
6083
|
+
const newStart = target.start + getColumnDeltaBefore(uniqueTargets, replacements, target.rowIndex, target.start);
|
|
6084
|
+
const newEnd = newStart + replacement.length;
|
|
6085
|
+
if (target.selectionStart === target.selectionEnd) {
|
|
6086
|
+
const originalOffset = target.selectionEnd - target.start;
|
|
6087
|
+
const newOffset = originalOffset === target.value.length ? replacement.length : Math.min(originalOffset, replacement.length);
|
|
6088
|
+
newSelections[index + 1] = newStart + newOffset;
|
|
6089
|
+
newSelections[index + 3] = newStart + newOffset;
|
|
6090
|
+
} else if (target.selectionStart < target.selectionEnd) {
|
|
6091
|
+
newSelections[index + 1] = newStart;
|
|
6092
|
+
newSelections[index + 3] = newEnd;
|
|
6093
|
+
} else {
|
|
6094
|
+
newSelections[index + 1] = newEnd;
|
|
6095
|
+
newSelections[index + 3] = newStart;
|
|
6096
|
+
}
|
|
6097
|
+
}
|
|
6098
|
+
return newSelections;
|
|
6099
|
+
};
|
|
6100
|
+
const changeSelectedValue = async (editor, delta) => {
|
|
6101
|
+
const targets = getTargets(editor);
|
|
6102
|
+
const uniqueTargets = getUniqueTargets(targets);
|
|
6103
|
+
if (uniqueTargets.length === 0) {
|
|
6104
|
+
return editor;
|
|
6105
|
+
}
|
|
6106
|
+
const replacements = new Map(uniqueTargets.map(target => [target, changeValue(target.value, delta, targets.find(candidate => candidate === target)?.activeOffset)]));
|
|
6107
|
+
const changedTargets = uniqueTargets.filter(target => replacements.get(target) !== target.value);
|
|
6108
|
+
if (changedTargets.length === 0) {
|
|
6109
|
+
return editor;
|
|
6110
|
+
}
|
|
6111
|
+
const changedTargetKeys = new Set(changedTargets.map(target => `${target.rowIndex}:${target.start}:${target.end}`));
|
|
6112
|
+
const selectionTargetsWithChanges = targets.filter(target => changedTargetKeys.has(`${target.rowIndex}:${target.start}:${target.end}`));
|
|
6113
|
+
const changes = [];
|
|
6114
|
+
const rowDeltas = new Map();
|
|
6115
|
+
for (const target of changedTargets) {
|
|
6116
|
+
const columnDelta = rowDeltas.get(target.rowIndex) ?? 0;
|
|
6117
|
+
const startColumn = target.start + columnDelta;
|
|
6118
|
+
const endColumn = target.end + columnDelta;
|
|
6119
|
+
const replacement = replacements.get(target);
|
|
6120
|
+
changes.push({
|
|
6121
|
+
deleted: [target.value],
|
|
6122
|
+
end: {
|
|
6123
|
+
columnIndex: endColumn,
|
|
6124
|
+
rowIndex: target.rowIndex
|
|
6125
|
+
},
|
|
6126
|
+
inserted: [replacement],
|
|
6127
|
+
origin: 'changeSelectedValue',
|
|
6128
|
+
start: {
|
|
6129
|
+
columnIndex: startColumn,
|
|
6130
|
+
rowIndex: target.rowIndex
|
|
6131
|
+
}
|
|
6132
|
+
});
|
|
6133
|
+
rowDeltas.set(target.rowIndex, columnDelta + replacement.length - target.value.length);
|
|
6134
|
+
}
|
|
6135
|
+
const newSelections = getNewSelections$b(editor, selectionTargetsWithChanges, changedTargets, replacements);
|
|
6136
|
+
return scheduleDocumentAndCursorsSelections(editor, changes, newSelections);
|
|
6137
|
+
};
|
|
6138
|
+
|
|
6139
|
+
const decrementSelection = editor => {
|
|
6140
|
+
return changeSelectedValue(editor, -1);
|
|
6141
|
+
};
|
|
6142
|
+
const incrementSelection = editor => {
|
|
6143
|
+
return changeSelectedValue(editor, 1);
|
|
6144
|
+
};
|
|
6145
|
+
|
|
5900
6146
|
const isMatchingWidget$2 = widget => {
|
|
5901
6147
|
return widget.id === CodeGenerator;
|
|
5902
6148
|
};
|
|
@@ -6696,7 +6942,7 @@ const cursorPageDown = editor => {
|
|
|
6696
6942
|
moveRangeToPosition$1(result, index, Math.min(endRow + pageSize, lastRowIndex), endColumn);
|
|
6697
6943
|
});
|
|
6698
6944
|
const newEditor = scheduleSelections(editor, newSelections);
|
|
6699
|
-
return setDeltaYFixedValue
|
|
6945
|
+
return setDeltaYFixedValue(newEditor, deltaY + pageSize * itemHeight);
|
|
6700
6946
|
};
|
|
6701
6947
|
|
|
6702
6948
|
const cursorSet = (editor, rowIndex, columnIndex) => {
|
|
@@ -7209,10 +7455,12 @@ const DeleteLine = 'Delete Line';
|
|
|
7209
7455
|
const EditorCloseColorPicker = 'Editor: Close Color Picker';
|
|
7210
7456
|
const EditorCopyLineDown = 'Editor: Copy Line Down';
|
|
7211
7457
|
const EditorCopyLineUp = 'Editor: Copy Line Up';
|
|
7458
|
+
const EditorDecrementSelection = 'Editor: Decrement Selection';
|
|
7212
7459
|
const EditorFormatDocumentForced = 'Editor: Format Document (forced)';
|
|
7213
7460
|
const EditorGoToDefinition = 'Editor: Go To Definition';
|
|
7214
7461
|
const EditorGoToTypeDefinition = 'Editor: Go To Type Definition';
|
|
7215
7462
|
const EditorIndent = 'Editor: Indent';
|
|
7463
|
+
const EditorIncrementSelection = 'Editor: Increment Selection';
|
|
7216
7464
|
const EditorOpenColorPicker = 'Editor: Open Color Picker';
|
|
7217
7465
|
const EditorSelectAllOccurrences = 'Editor: Select All Occurrences';
|
|
7218
7466
|
const EditorSelectDown = 'Editor: Select Down';
|
|
@@ -7348,6 +7596,9 @@ const editorSelectInsideString = () => {
|
|
|
7348
7596
|
const editorIndent = () => {
|
|
7349
7597
|
return i18nString(EditorIndent);
|
|
7350
7598
|
};
|
|
7599
|
+
const editorIncrementSelection = () => {
|
|
7600
|
+
return i18nString(EditorIncrementSelection);
|
|
7601
|
+
};
|
|
7351
7602
|
const editorUnindent$1 = () => {
|
|
7352
7603
|
return i18nString(EditorUnindent);
|
|
7353
7604
|
};
|
|
@@ -7357,6 +7608,9 @@ const editorSortLinesAscending = () => {
|
|
|
7357
7608
|
const editorToggleComment = () => {
|
|
7358
7609
|
return i18nString(EditorToggleComment);
|
|
7359
7610
|
};
|
|
7611
|
+
const editorDecrementSelection = () => {
|
|
7612
|
+
return i18nString(EditorDecrementSelection);
|
|
7613
|
+
};
|
|
7360
7614
|
const editorSelectUp = () => {
|
|
7361
7615
|
return i18nString(EditorSelectUp);
|
|
7362
7616
|
};
|
|
@@ -8628,7 +8882,7 @@ const handleScrollBarMove = async (state, eventY) => {
|
|
|
8628
8882
|
const relativeY = eventY - y - handleOffset;
|
|
8629
8883
|
const newPercent = getNewPercent(state, relativeY);
|
|
8630
8884
|
const newDeltaY = newPercent * finalDeltaY;
|
|
8631
|
-
const newState = await setDeltaYFixedValue
|
|
8885
|
+
const newState = await setDeltaYFixedValue(state, newDeltaY);
|
|
8632
8886
|
return newState;
|
|
8633
8887
|
};
|
|
8634
8888
|
const handleScrollBarVerticalPointerMove = handleScrollBarMove;
|
|
@@ -8661,7 +8915,7 @@ const handleScrollBarPointerDown = async (state, eventY) => {
|
|
|
8661
8915
|
percent
|
|
8662
8916
|
} = getNewDeltaPercent(height, scrollBarHeight, relativeY);
|
|
8663
8917
|
const newDeltaY = percent * finalDeltaY;
|
|
8664
|
-
const newState = await setDeltaYFixedValue
|
|
8918
|
+
const newState = await setDeltaYFixedValue(state, newDeltaY);
|
|
8665
8919
|
return {
|
|
8666
8920
|
...newState,
|
|
8667
8921
|
handleOffset
|
|
@@ -8709,13 +8963,9 @@ const handleTouchStart = (editor, touchEvent) => {
|
|
|
8709
8963
|
};
|
|
8710
8964
|
|
|
8711
8965
|
// @ts-ignore
|
|
8712
|
-
const
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
// @ts-ignore
|
|
8717
|
-
const setDeltaYFixedValue = (editor, deltaY) => {
|
|
8718
|
-
return setDeltaYFixedValue$1(editor, deltaY);
|
|
8966
|
+
const scrollByLines = (editor, lineCount) => {
|
|
8967
|
+
number(lineCount);
|
|
8968
|
+
return setDeltaY(editor, lineCount * editor.itemHeight);
|
|
8719
8969
|
};
|
|
8720
8970
|
|
|
8721
8971
|
// @ts-ignore
|
|
@@ -11739,6 +11989,13 @@ const getLines2 = editorUid => {
|
|
|
11739
11989
|
} = editor;
|
|
11740
11990
|
return lines;
|
|
11741
11991
|
};
|
|
11992
|
+
const getVisibleLineRange = editorUid => {
|
|
11993
|
+
const {
|
|
11994
|
+
maxLineY,
|
|
11995
|
+
minLineY
|
|
11996
|
+
} = getEditor$1(editorUid);
|
|
11997
|
+
return [minLineY, maxLineY];
|
|
11998
|
+
};
|
|
11742
11999
|
const getSelections2 = editorUid => {
|
|
11743
12000
|
const editor = getEditor$1(editorUid);
|
|
11744
12001
|
const {
|
|
@@ -11921,6 +12178,14 @@ const getKeyBindings = () => {
|
|
|
11921
12178
|
command: 'Editor.cursorDocumentStart',
|
|
11922
12179
|
key: CtrlCmd | Home,
|
|
11923
12180
|
when: FocusEditorText
|
|
12181
|
+
}, {
|
|
12182
|
+
command: 'Editor.incrementSelection',
|
|
12183
|
+
key: CtrlCmd | Alt$1 | KeyI,
|
|
12184
|
+
when: FocusEditorText
|
|
12185
|
+
}, {
|
|
12186
|
+
command: 'Editor.decrementSelection',
|
|
12187
|
+
key: CtrlCmd | Alt$1 | KeyD,
|
|
12188
|
+
when: FocusEditorText
|
|
11924
12189
|
}, {
|
|
11925
12190
|
command: 'Editor.deleteWordPartLeft',
|
|
11926
12191
|
key: Alt$1 | Backspace,
|
|
@@ -12303,6 +12568,12 @@ const getQuickPickMenuEntries = () => {
|
|
|
12303
12568
|
}, {
|
|
12304
12569
|
id: 'Editor.deleteLine',
|
|
12305
12570
|
label: deleteLine()
|
|
12571
|
+
}, {
|
|
12572
|
+
id: 'Editor.incrementSelection',
|
|
12573
|
+
label: editorIncrementSelection()
|
|
12574
|
+
}, {
|
|
12575
|
+
id: 'Editor.decrementSelection',
|
|
12576
|
+
label: editorDecrementSelection()
|
|
12306
12577
|
}, {
|
|
12307
12578
|
id: 'Editor.format',
|
|
12308
12579
|
label: formatDocument()
|
|
@@ -12522,16 +12793,24 @@ const applyTabCompletion = (editor, result) => {
|
|
|
12522
12793
|
return editorSnippet(editor, result);
|
|
12523
12794
|
};
|
|
12524
12795
|
|
|
12796
|
+
const insertTab = editor => {
|
|
12797
|
+
// TODO have setting what should be inserted on tab
|
|
12798
|
+
return type(editor, ' ');
|
|
12799
|
+
};
|
|
12525
12800
|
const handleTab = async editor => {
|
|
12526
12801
|
if (!isEverySelectionEmpty(editor.selections)) {
|
|
12527
12802
|
return indentMore(editor);
|
|
12528
12803
|
}
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
12804
|
+
try {
|
|
12805
|
+
const result = await getTabCompletion(editor);
|
|
12806
|
+
if (!result) {
|
|
12807
|
+
return insertTab(editor);
|
|
12808
|
+
}
|
|
12809
|
+
return applyTabCompletion(editor, result);
|
|
12810
|
+
} catch (error) {
|
|
12811
|
+
await handleError$1(error, 'Failed to execute tab completion provider: ');
|
|
12812
|
+
return insertTab(editor);
|
|
12533
12813
|
}
|
|
12534
|
-
return applyTabCompletion(editor, result);
|
|
12535
12814
|
};
|
|
12536
12815
|
|
|
12537
12816
|
const relaunchWorkers = async () => {
|
|
@@ -14265,6 +14544,7 @@ const commandMap = {
|
|
|
14265
14544
|
'Editor.cursorWordPartRight': wrapCommand(cursorWordPartRight),
|
|
14266
14545
|
'Editor.cursorWordRight': wrapCommand(cursorWordRight),
|
|
14267
14546
|
'Editor.cut': wrapCommand(cut$1),
|
|
14547
|
+
'Editor.decrementSelection': wrapCommand(decrementSelection),
|
|
14268
14548
|
'Editor.deleteAll': wrapCommand(deleteAll),
|
|
14269
14549
|
'Editor.deleteAllLeft': wrapCommand(deleteAllLeft),
|
|
14270
14550
|
'Editor.deleteAllRight': wrapCommand(deleteAllRight),
|
|
@@ -14302,6 +14582,7 @@ const commandMap = {
|
|
|
14302
14582
|
'Editor.getSourceActions': getSourceActions,
|
|
14303
14583
|
'Editor.getText': getText,
|
|
14304
14584
|
'Editor.getUri': getUri,
|
|
14585
|
+
'Editor.getVisibleLineRange': getVisibleLineRange,
|
|
14305
14586
|
'Editor.getWordAt': getWordAt$1,
|
|
14306
14587
|
'Editor.getWordAt2': getWordAt,
|
|
14307
14588
|
'Editor.getWordAtOffset2': getWordAtOffset2,
|
|
@@ -14344,6 +14625,7 @@ const commandMap = {
|
|
|
14344
14625
|
'Editor.handleUriChange': wrapCommand(handleUriChange),
|
|
14345
14626
|
'Editor.handleWheel': wrapCommand(handleWheel$2),
|
|
14346
14627
|
'Editor.hotReload': hotReload,
|
|
14628
|
+
'Editor.incrementSelection': wrapCommand(incrementSelection),
|
|
14347
14629
|
'Editor.indendLess': wrapCommand(indentLess),
|
|
14348
14630
|
'Editor.indentMore': wrapCommand(indentMore),
|
|
14349
14631
|
'Editor.insertLineBreak': wrapCommand(insertLineBreak),
|
|
@@ -14373,6 +14655,7 @@ const commandMap = {
|
|
|
14373
14655
|
'Editor.resize': wrapCommand(resize),
|
|
14374
14656
|
'Editor.save': wrapCommand(save),
|
|
14375
14657
|
'Editor.saveState': wrapGetter(saveState),
|
|
14658
|
+
'Editor.scrollByLines': wrapCommand(scrollByLines),
|
|
14376
14659
|
'Editor.selectAll': wrapCommand(selectAll),
|
|
14377
14660
|
'Editor.selectAllLeft': wrapCommand(editorSelectAllLeft),
|
|
14378
14661
|
'Editor.selectAllOccurrences': wrapCommand(selectAllOccurrences),
|