@mongoosejs/studio 0.7.0 → 0.7.1

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.
@@ -29348,7 +29348,7 @@ var reportErrorIfPathIsNotConfigured = function () {
29348
29348
  reportErrorIfPathIsNotConfigured = function () { };
29349
29349
  }
29350
29350
  };
29351
- exports.version = "1.44.0";
29351
+ exports.version = "1.45.0";
29352
29352
 
29353
29353
  });
29354
29354
 
@@ -32495,14 +32495,15 @@ var MouseHandler = /** @class */ (function () {
32495
32495
  var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
32496
32496
  var range = editor.session.selection.getRange();
32497
32497
  var renderer = editor.renderer;
32498
+ if (renderer.scroller.style.cursor == "crosshair")
32499
+ return;
32498
32500
  if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
32499
32501
  renderer.setCursorStyle("default");
32500
32502
  }
32501
32503
  else {
32502
32504
  renderer.setCursorStyle("");
32503
32505
  }
32504
- }, //@ts-expect-error TODO: seems mistyping - should be boolean
32505
- editor);
32506
+ });
32506
32507
  }
32507
32508
  MouseHandler.prototype.onMouseEvent = function (name, e) {
32508
32509
  if (!this.editor.session)
@@ -33123,12 +33124,7 @@ var BidiHandler = /** @class */ (function () {
33123
33124
  BidiHandler.prototype.isBidiRow = function (screenRow, docRow, splitIndex) {
33124
33125
  if (!this.seenBidi)
33125
33126
  return false;
33126
- if (screenRow !== this.currentRow) {
33127
- this.currentRow = screenRow;
33128
- this.updateRowLine(docRow, splitIndex);
33129
- this.updateBidiMap();
33130
- }
33131
- return this.bidiMap.bidiLevels;
33127
+ return true;
33132
33128
  };
33133
33129
  BidiHandler.prototype.onChange = function (delta) {
33134
33130
  if (!this.seenBidi) {
@@ -33169,74 +33165,9 @@ var BidiHandler = /** @class */ (function () {
33169
33165
  }
33170
33166
  return splitIndex;
33171
33167
  };
33172
- BidiHandler.prototype.updateRowLine = function (docRow, splitIndex) {
33173
- if (docRow === undefined)
33174
- docRow = this.getDocumentRow();
33175
- var isLastRow = (docRow === this.session.getLength() - 1), endOfLine = isLastRow ? this.EOF : this.EOL;
33176
- this.wrapIndent = 0;
33177
- this.line = this.session.getLine(docRow);
33178
- this.isRtlDir = this.$isRtl || this.line.charAt(0) === this.RLE;
33179
- if (this.session.$useWrapMode) {
33180
- var splits = this.session.$wrapData[docRow];
33181
- if (splits) {
33182
- if (splitIndex === undefined)
33183
- splitIndex = this.getSplitIndex();
33184
- if (splitIndex > 0 && splits.length) {
33185
- this.wrapIndent = splits.indent;
33186
- this.wrapOffset = this.wrapIndent * this.charWidths[bidiUtil.L];
33187
- this.line = (splitIndex < splits.length) ?
33188
- this.line.substring(splits[splitIndex - 1], splits[splitIndex]) :
33189
- this.line.substring(splits[splits.length - 1]);
33190
- }
33191
- else {
33192
- this.line = this.line.substring(0, splits[splitIndex]);
33193
- }
33194
- if (splitIndex == splits.length) {
33195
- this.line += (this.showInvisibles) ? endOfLine : bidiUtil.DOT;
33196
- }
33197
- }
33198
- }
33199
- else {
33200
- this.line += this.showInvisibles ? endOfLine : bidiUtil.DOT;
33201
- }
33202
- var session = this.session, shift = 0, size;
33203
- this.line = this.line.replace(/\t|[\u1100-\u2029, \u202F-\uFFE6]/g, function (ch, i) {
33204
- if (ch === '\t' || session.isFullWidth(ch.charCodeAt(0))) {
33205
- size = (ch === '\t') ? session.getScreenTabSize(i + shift) : 2;
33206
- shift += size - 1;
33207
- return lang.stringRepeat(bidiUtil.DOT, size);
33208
- }
33209
- return ch;
33210
- });
33211
- if (this.isRtlDir) {
33212
- this.fontMetrics.$main.textContent = (this.line.charAt(this.line.length - 1) == bidiUtil.DOT) ? this.line.substr(0, this.line.length - 1) : this.line;
33213
- this.rtlLineOffset = this.contentWidth - this.fontMetrics.$main.getBoundingClientRect().width;
33214
- }
33215
- };
33216
- BidiHandler.prototype.updateBidiMap = function () {
33217
- var textCharTypes = [];
33218
- if (bidiUtil.hasBidiCharacters(this.line, textCharTypes) || this.isRtlDir) {
33219
- this.bidiMap = bidiUtil.doBidiReorder(this.line, textCharTypes, this.isRtlDir);
33220
- }
33221
- else {
33222
- this.bidiMap = {};
33223
- }
33224
- };
33225
33168
  BidiHandler.prototype.markAsDirty = function () {
33226
33169
  this.currentRow = null;
33227
33170
  };
33228
- BidiHandler.prototype.updateCharacterWidths = function (fontMetrics) {
33229
- if (this.characterWidth === fontMetrics.$characterSize.width)
33230
- return;
33231
- this.fontMetrics = fontMetrics;
33232
- var characterWidth = this.characterWidth = fontMetrics.$characterSize.width;
33233
- var bidiCharWidth = fontMetrics.$measureCharWidth("\u05d4");
33234
- this.charWidths[bidiUtil.L] = this.charWidths[bidiUtil.EN] = this.charWidths[bidiUtil.ON_R] = characterWidth;
33235
- this.charWidths[bidiUtil.R] = this.charWidths[bidiUtil.AN] = bidiCharWidth;
33236
- this.charWidths[bidiUtil.R_H] = bidiCharWidth * 0.45;
33237
- this.charWidths[bidiUtil.B] = this.charWidths[bidiUtil.RLE] = 0;
33238
- this.currentRow = null;
33239
- };
33240
33171
  BidiHandler.prototype.setShowInvisibles = function (showInvisibles) {
33241
33172
  this.showInvisibles = showInvisibles;
33242
33173
  this.currentRow = null;
@@ -33264,87 +33195,6 @@ var BidiHandler = /** @class */ (function () {
33264
33195
  editor.session.doc.insert({ column: 0, row: row }, editor.session.$bidiHandler.RLE);
33265
33196
  }
33266
33197
  };
33267
- BidiHandler.prototype.getPosLeft = function (col) {
33268
- col -= this.wrapIndent;
33269
- var leftBoundary = (this.line.charAt(0) === this.RLE) ? 1 : 0;
33270
- var logicalIdx = (col > leftBoundary) ? (this.session.getOverwrite() ? col : col - 1) : leftBoundary;
33271
- var visualIdx = bidiUtil.getVisualFromLogicalIdx(logicalIdx, this.bidiMap), levels = this.bidiMap.bidiLevels, left = 0;
33272
- if (!this.session.getOverwrite() && col <= leftBoundary && levels[visualIdx] % 2 !== 0)
33273
- visualIdx++;
33274
- for (var i = 0; i < visualIdx; i++) {
33275
- left += this.charWidths[levels[i]];
33276
- }
33277
- if (!this.session.getOverwrite() && (col > leftBoundary) && (levels[visualIdx] % 2 === 0))
33278
- left += this.charWidths[levels[visualIdx]];
33279
- if (this.wrapIndent)
33280
- left += this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset;
33281
- if (this.isRtlDir)
33282
- left += this.rtlLineOffset;
33283
- return left;
33284
- };
33285
- BidiHandler.prototype.getSelections = function (startCol, endCol) {
33286
- var map = this.bidiMap, levels = map.bidiLevels, level, selections = [], offset = 0, selColMin = Math.min(startCol, endCol) - this.wrapIndent, selColMax = Math.max(startCol, endCol) - this.wrapIndent, isSelected = false, isSelectedPrev = false, selectionStart = 0;
33287
- if (this.wrapIndent)
33288
- offset += this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset;
33289
- for (var logIdx, visIdx = 0; visIdx < levels.length; visIdx++) {
33290
- logIdx = map.logicalFromVisual[visIdx];
33291
- level = levels[visIdx];
33292
- isSelected = (logIdx >= selColMin) && (logIdx < selColMax);
33293
- if (isSelected && !isSelectedPrev) {
33294
- selectionStart = offset;
33295
- }
33296
- else if (!isSelected && isSelectedPrev) {
33297
- selections.push({ left: selectionStart, width: offset - selectionStart });
33298
- }
33299
- offset += this.charWidths[level];
33300
- isSelectedPrev = isSelected;
33301
- }
33302
- if (isSelected && (visIdx === levels.length)) {
33303
- selections.push({ left: selectionStart, width: offset - selectionStart });
33304
- }
33305
- if (this.isRtlDir) {
33306
- for (var i = 0; i < selections.length; i++) {
33307
- selections[i].left += this.rtlLineOffset;
33308
- }
33309
- }
33310
- return selections;
33311
- };
33312
- BidiHandler.prototype.offsetToCol = function (posX) {
33313
- if (this.isRtlDir)
33314
- posX -= this.rtlLineOffset;
33315
- var logicalIdx = 0, posX = Math.max(posX, 0), offset = 0, visualIdx = 0, levels = this.bidiMap.bidiLevels, charWidth = this.charWidths[levels[visualIdx]];
33316
- if (this.wrapIndent)
33317
- posX -= this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset;
33318
- while (posX > offset + charWidth / 2) {
33319
- offset += charWidth;
33320
- if (visualIdx === levels.length - 1) {
33321
- charWidth = 0;
33322
- break;
33323
- }
33324
- charWidth = this.charWidths[levels[++visualIdx]];
33325
- }
33326
- if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && (levels[visualIdx] % 2 === 0)) {
33327
- if (posX < offset)
33328
- visualIdx--;
33329
- logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
33330
- }
33331
- else if (visualIdx > 0 && (levels[visualIdx - 1] % 2 === 0) && (levels[visualIdx] % 2 !== 0)) {
33332
- logicalIdx = 1 + ((posX > offset) ? this.bidiMap.logicalFromVisual[visualIdx]
33333
- : this.bidiMap.logicalFromVisual[visualIdx - 1]);
33334
- }
33335
- else if ((this.isRtlDir && visualIdx === levels.length - 1 && charWidth === 0 && (levels[visualIdx - 1] % 2 === 0))
33336
- || (!this.isRtlDir && visualIdx === 0 && (levels[visualIdx] % 2 !== 0))) {
33337
- logicalIdx = 1 + this.bidiMap.logicalFromVisual[visualIdx];
33338
- }
33339
- else {
33340
- if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && charWidth !== 0)
33341
- visualIdx--;
33342
- logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
33343
- }
33344
- if (logicalIdx === 0 && this.isRtlDir)
33345
- logicalIdx++;
33346
- return (logicalIdx + this.wrapIndent);
33347
- };
33348
33198
  return BidiHandler;
33349
33199
  }());
33350
33200
  exports.BidiHandler = BidiHandler;
@@ -33776,15 +33626,13 @@ var Selection = /** @class */ (function () {
33776
33626
  Selection.prototype.moveCursorBy = function (rows, chars) {
33777
33627
  var screenPos = this.session.documentToScreenPosition(this.lead.row, this.lead.column);
33778
33628
  var offsetX;
33629
+ var fontMetrics = this.session.$fontMetrics;
33630
+ var useFontMetrics = chars === 0 && rows !== 0 && fontMetrics;
33779
33631
  if (chars === 0) {
33780
- if (rows !== 0) {
33781
- if (this.session.$bidiHandler.isBidiRow(screenPos.row, this.lead.row)) {
33782
- offsetX = this.session.$bidiHandler.getPosLeft(screenPos.column);
33783
- screenPos.column = Math.round(offsetX / this.session.$bidiHandler.charWidths[0]);
33784
- }
33785
- else {
33786
- offsetX = screenPos.column * this.session.$bidiHandler.charWidths[0];
33787
- }
33632
+ if (useFontMetrics && this.$desiredColumn == null) {
33633
+ offsetX = fontMetrics.textWidth(screenPos.row, screenPos.column);
33634
+ if (isFinite(offsetX))
33635
+ this.$desiredColumn = offsetX / fontMetrics.config.characterWidth;
33788
33636
  }
33789
33637
  if (this.$desiredColumn)
33790
33638
  screenPos.column = this.$desiredColumn;
@@ -33798,9 +33646,13 @@ var Selection = /** @class */ (function () {
33798
33646
  else if (rows > 0)
33799
33647
  rows += widget.rowCount - (widget.rowsAbove || 0);
33800
33648
  }
33801
- var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column, offsetX);
33802
- if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
33649
+ var targetScreenRow = screenPos.row + rows;
33650
+ if (useFontMetrics && this.$desiredColumn != null) {
33651
+ offsetX = this.$desiredColumn * fontMetrics.config.characterWidth;
33652
+ var blockCursor = fontMetrics.renderer && fontMetrics.renderer.$blockCursor;
33653
+ screenPos.column = fontMetrics.$pixelToColumn(targetScreenRow, screenPos.column, offsetX, blockCursor, true);
33803
33654
  }
33655
+ var docPos = this.session.screenToDocumentPosition(targetScreenRow, screenPos.column);
33804
33656
  this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
33805
33657
  };
33806
33658
  Selection.prototype.moveCursorToPosition = function (position) {
@@ -34071,6 +33923,37 @@ var Tokenizer = /** @class */ (function () {
34071
33923
  if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
34072
33924
  src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
34073
33925
  }
33926
+ var leadingLookbehind;
33927
+ while ((leadingLookbehind = /^(?:\((?:\?:)?)*\(\?<[=!]/.exec(src))) {
33928
+ var start = leadingLookbehind[0].length - 4;
33929
+ var end = -1;
33930
+ var depth = 0;
33931
+ var inClass = false;
33932
+ var re = /\\.|[\[\]()]/g;
33933
+ re.lastIndex = start;
33934
+ var m;
33935
+ while ((m = re.exec(src))) {
33936
+ var ch = m[0];
33937
+ if (ch.length > 1)
33938
+ continue;
33939
+ if (inClass) {
33940
+ inClass = ch != "]";
33941
+ }
33942
+ else if (ch == "[") {
33943
+ inClass = true;
33944
+ }
33945
+ else if (ch == "(") {
33946
+ depth++;
33947
+ }
33948
+ else if (ch == ")" && --depth == 0) {
33949
+ end = m.index + 1;
33950
+ break;
33951
+ }
33952
+ }
33953
+ if (end == -1)
33954
+ break;
33955
+ src = src.substring(0, start) + src.substr(end);
33956
+ }
34074
33957
  if (src.charAt(0) != "^")
34075
33958
  src = "^" + src;
34076
33959
  if (src.charAt(src.length - 1) != "$")
@@ -36295,9 +36178,11 @@ var SearchHighlight = /** @class */ (function () {
36295
36178
  var renderedMarkerRanges = {};
36296
36179
  var _search = session.$editor && session.$editor.$search;
36297
36180
  var mtSearch = _search && _search.$isMultilineSearch(session.$editor.getLastSearchOptions());
36181
+ var docLen = session.getValue().length;
36182
+ var cacheInvalid = docLen != this.docLen;
36298
36183
  for (var i = start; i <= end; i++) {
36299
36184
  var ranges = this.cache[i];
36300
- if (ranges == null || session.getValue().length != this.docLen) {
36185
+ if (ranges == null || cacheInvalid) {
36301
36186
  if (mtSearch) {
36302
36187
  ranges = [];
36303
36188
  var match = _search.$multiLineForward(session, this.regExp, i, end);
@@ -36331,7 +36216,7 @@ var SearchHighlight = /** @class */ (function () {
36331
36216
  markerLayer.drawSingleLineMarker(html, rangeToAddMarkerTo, this.clazz, config);
36332
36217
  }
36333
36218
  }
36334
- this.docLen = session.getValue().length;
36219
+ this.docLen = docLen;
36335
36220
  };
36336
36221
  return SearchHighlight;
36337
36222
  }());
@@ -36515,8 +36400,10 @@ var UndoManager = /** @class */ (function () {
36515
36400
  };
36516
36401
  UndoManager.prototype.fromJSON = function (json) {
36517
36402
  this.reset();
36518
- this.$undoStack = json.$undoStack;
36519
- this.$redoStack = json.$redoStack;
36403
+ if (!json)
36404
+ return;
36405
+ this.$undoStack = json.$undoStack || [];
36406
+ this.$redoStack = json.$redoStack || [];
36520
36407
  };
36521
36408
  UndoManager.prototype.$prettyPrint = function (delta) {
36522
36409
  if (delta)
@@ -38638,10 +38525,12 @@ var EditSession = /** @class */ (function () {
38638
38525
  if (typeof session == "string")
38639
38526
  session = JSON.parse(session);
38640
38527
  var undoManager = new UndoManager();
38641
- undoManager.$undoStack = session.history.$undoStack;
38642
- undoManager.$redoStack = session.history.$redoStack;
38643
- undoManager.mark = session.history.mark;
38644
- undoManager.$rev = session.history.rev;
38528
+ if (session.history) {
38529
+ undoManager.$undoStack = session.history.$undoStack || [];
38530
+ undoManager.$redoStack = session.history.$redoStack || [];
38531
+ undoManager.mark = session.history.mark || 0;
38532
+ undoManager.$rev = session.history.rev || 0;
38533
+ }
38645
38534
  var editSession = new EditSession(session.value);
38646
38535
  session.folds.forEach(function (fold) {
38647
38536
  editSession.addFold("...", Range.fromPoints(fold.start, fold.end));
@@ -39685,9 +39574,6 @@ var EditSession = /** @class */ (function () {
39685
39574
  if (c == 9) {
39686
39575
  screenColumn += this.getScreenTabSize(screenColumn);
39687
39576
  }
39688
- else if (c >= 0x1100 && isFullWidth(c)) {
39689
- screenColumn += 2;
39690
- }
39691
39577
  else {
39692
39578
  screenColumn += 1;
39693
39579
  }
@@ -39753,7 +39639,7 @@ var EditSession = /** @class */ (function () {
39753
39639
  EditSession.prototype.screenToDocumentColumn = function (screenRow, screenColumn) {
39754
39640
  return this.screenToDocumentPosition(screenRow, screenColumn).column;
39755
39641
  };
39756
- EditSession.prototype.screenToDocumentPosition = function (screenRow, screenColumn, offsetX) {
39642
+ EditSession.prototype.screenToDocumentPosition = function (screenRow, screenColumn) {
39757
39643
  if (screenRow < 0)
39758
39644
  return { row: 0, column: 0 };
39759
39645
  var line;
@@ -39821,8 +39707,6 @@ var EditSession = /** @class */ (function () {
39821
39707
  }
39822
39708
  }
39823
39709
  }
39824
- if (offsetX !== undefined && this.$bidiHandler.isBidiRow(row + splitIndex, docRow, splitIndex))
39825
- screenColumn = this.$bidiHandler.offsetToCol(offsetX);
39826
39710
  docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
39827
39711
  if (this.$useWrapMode && docColumn >= column)
39828
39712
  docColumn = column - 1;
@@ -42473,6 +42357,7 @@ var Editor = /** @class */ (function () {
42473
42357
  this.session.off("startOperation", this.$onStartOperation);
42474
42358
  this.session.off("endOperation", this.$onEndOperation);
42475
42359
  var selection = this.session.getSelection();
42360
+ this.session.$fontMetrics = null;
42476
42361
  selection.off("changeCursor", this.$onCursorChange);
42477
42362
  selection.off("changeSelection", this.$onSelectionChange);
42478
42363
  }
@@ -42481,6 +42366,7 @@ var Editor = /** @class */ (function () {
42481
42366
  this.$onDocumentChange = this.onDocumentChange.bind(this);
42482
42367
  session.on("change", this.$onDocumentChange);
42483
42368
  this.renderer.setSession(session);
42369
+ session.$fontMetrics = this.renderer.$fontMetrics;
42484
42370
  this.$onChangeMode = this.onChangeMode.bind(this);
42485
42371
  session.on("changeMode", this.$onChangeMode);
42486
42372
  this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
@@ -44376,6 +44262,24 @@ var Lines = /** @class */ (function () {
44376
44262
  var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight;
44377
44263
  return lineTop - (screenPage * this.canvasHeight);
44378
44264
  };
44265
+ Lines.prototype.$getCellByScreenRow = function (screenRow, config) {
44266
+ var screenTop = config.firstRowScreen * config.lineHeight;
44267
+ var screenPage = Math.floor(screenTop / this.canvasHeight);
44268
+ var lineTop = screenRow * config.lineHeight - (screenPage * this.canvasHeight);
44269
+ for (var i = this.cells.length - 1; i >= 0; i--) {
44270
+ var cell = this.cells[i];
44271
+ var top = parseInt(cell.element.style.top);
44272
+ var height = parseInt(cell.element.style.height);
44273
+ if (top <= lineTop) {
44274
+ if (top + height < lineTop) {
44275
+ return null;
44276
+ }
44277
+ var offset = lineTop - top;
44278
+ return { cell: cell, offset: offset };
44279
+ }
44280
+ }
44281
+ return null;
44282
+ };
44379
44283
  Lines.prototype.computeLineHeight = function (row, config, session) {
44380
44284
  return config.lineHeight * session.getRowLineCount(row);
44381
44285
  };
@@ -45087,6 +44991,7 @@ var Marker = /** @class */ (function () {
45087
44991
  if (!config)
45088
44992
  return;
45089
44993
  this.config = config;
44994
+ this.element.style.display = "none";
45090
44995
  this.i = 0;
45091
44996
  var html;
45092
44997
  for (var key in this.markers) {
@@ -45101,7 +45006,7 @@ var Marker = /** @class */ (function () {
45101
45006
  range = range.toScreenRange(this.session);
45102
45007
  if (marker.renderer) {
45103
45008
  var top = this.$getTop(range.start.row, config);
45104
- var left = this.$padding + range.start.column * config.characterWidth;
45009
+ var left = this.$padding + config.fontMetrics.textWidth(range.start.row, range.start.column);
45105
45010
  marker.renderer(html, range, left, top, config);
45106
45011
  }
45107
45012
  else if (marker.type == "fullLine") {
@@ -45124,6 +45029,7 @@ var Marker = /** @class */ (function () {
45124
45029
  while (this.i < this.element.childElementCount)
45125
45030
  this.element.removeChild(this.element.lastChild);
45126
45031
  }
45032
+ this.element.style.display = "";
45127
45033
  };
45128
45034
  Marker.prototype.$getTop = function (row, layerConfig) {
45129
45035
  return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
@@ -45152,12 +45058,12 @@ var Marker = /** @class */ (function () {
45152
45058
  var padding = this.$padding;
45153
45059
  var height = config.lineHeight;
45154
45060
  var top = this.$getTop(range.start.row, config);
45155
- var left = padding + range.start.column * config.characterWidth;
45061
+ var left = padding + config.fontMetrics.textWidth(range.start.row, range.start.column);
45156
45062
  extraStyle = extraStyle || "";
45157
45063
  if (this.session.$bidiHandler.isBidiRow(range.start.row)) {
45158
45064
  var range1 = range.clone();
45159
45065
  range1.end.row = range1.start.row;
45160
- range1.end.column = this.session.getLine(range1.start.row).length;
45066
+ range1.end.column = Number.MAX_VALUE;
45161
45067
  this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle);
45162
45068
  }
45163
45069
  else {
@@ -45171,7 +45077,7 @@ var Marker = /** @class */ (function () {
45171
45077
  }
45172
45078
  else {
45173
45079
  top = this.$getTop(range.end.row, config);
45174
- var width = range.end.column * config.characterWidth;
45080
+ var width = config.fontMetrics.textWidth(range.end.row, range.end.column);
45175
45081
  this.elt(clazz + " ace_br12", "height:" + height + "px;" +
45176
45082
  "width:" + width + "px;" +
45177
45083
  "top:" + top + "px;" +
@@ -45191,22 +45097,22 @@ var Marker = /** @class */ (function () {
45191
45097
  if (this.session.$bidiHandler.isBidiRow(range.start.row))
45192
45098
  return this.drawBidiSingleLineMarker(stringBuilder, range, clazz, config, extraLength, extraStyle);
45193
45099
  var height = config.lineHeight;
45194
- var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
45100
+ var right = config.fontMetrics.textWidth(range.start.row, range.end.column) + (extraLength || 0) * config.characterWidth;
45195
45101
  var top = this.$getTop(range.start.row, config);
45196
- var left = this.$padding + range.start.column * config.characterWidth;
45102
+ var left = config.fontMetrics.textWidth(range.start.row, range.start.column);
45197
45103
  this.elt(clazz, "height:" + height + "px;" +
45198
- "width:" + width + "px;" +
45104
+ "width:" + (right - left) + "px;" +
45199
45105
  "top:" + top + "px;" +
45200
- "left:" + left + "px;" + (extraStyle || ""));
45106
+ "left:" + (this.$padding + left) + "px;" + (extraStyle || ""));
45201
45107
  };
45202
45108
  Marker.prototype.drawBidiSingleLineMarker = function (stringBuilder, range, clazz, config, extraLength, extraStyle) {
45203
45109
  var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding;
45204
- var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column);
45205
- selections.forEach(function (selection) {
45110
+ var rects = this.config.fontMetrics.getRects(range.start, range.end);
45111
+ rects.forEach(function (rect) {
45206
45112
  this.elt(clazz, "height:" + height + "px;" +
45207
- "width:" + (selection.width + (extraLength || 0)) + "px;" +
45113
+ "width:" + (rect.width + (extraLength || 0)) + "px;" +
45208
45114
  "top:" + top + "px;" +
45209
- "left:" + (padding + selection.left) + "px;" + (extraStyle || ""));
45115
+ "left:" + (padding + rect.left) + "px;" + (extraStyle || ""));
45210
45116
  }, this);
45211
45117
  };
45212
45118
  Marker.prototype.drawFullLineMarker = function (stringBuilder, range, clazz, config, extraStyle) {
@@ -45488,7 +45394,7 @@ var Text = /** @class */ (function () {
45488
45394
  };
45489
45395
  Text.prototype.$renderToken = function (parent, screenColumn, token, value) {
45490
45396
  var self = this;
45491
- var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC\u2066\u2067\u2068\u202A\u202B\u202D\u202E\u202C\u2069\u2060\u2061\u2062\u2063\u2064\u206A\u206B\u206B\u206C\u206D\u206E\u206F]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g;
45397
+ var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200C\u200E\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC\u2066\u2067\u2068\u202A\u202B\u202D\u202E\u202C\u2069\u2060\u2061\u2062\u2063\u2064\u206A\u206B\u206B\u206C\u206D\u206E\u206F]+)|(\u3000+)/g;
45492
45398
  var valueFragment = this.dom.createFragment(this.element);
45493
45399
  var m;
45494
45400
  var i = 0;
@@ -45497,7 +45403,6 @@ var Text = /** @class */ (function () {
45497
45403
  var simpleSpace = m[2];
45498
45404
  var controlCharacter = m[3];
45499
45405
  var cjkSpace = m[4];
45500
- var cjk = m[5];
45501
45406
  if (!self.showSpaces && simpleSpace)
45502
45407
  continue;
45503
45408
  var before = i != m.index ? value.slice(i, m.index) : "";
@@ -45530,23 +45435,26 @@ var Text = /** @class */ (function () {
45530
45435
  valueFragment.appendChild(span);
45531
45436
  }
45532
45437
  else if (cjkSpace) {
45533
- screenColumn += 1;
45534
- var span = this.dom.createElement("span");
45535
- span.style.width = (self.config.characterWidth * 2) + "px";
45536
- span.className = self.showSpaces ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
45537
- span.textContent = self.showSpaces ? self.SPACE_CHAR : cjkSpace;
45538
- valueFragment.appendChild(span);
45438
+ if (self.showSpaces) {
45439
+ var span = this.dom.createElement("span");
45440
+ span.className = "ace_invisible ace_invisible_space";
45441
+ span.textContent = lang.stringRepeat(self.CJK_SPACE_CHAR, cjkSpace.length);
45442
+ valueFragment.appendChild(span);
45443
+ }
45444
+ else {
45445
+ valueFragment.appendChild(this.dom.createTextNode(cjkSpace, this.element));
45446
+ }
45539
45447
  }
45540
- else if (cjk) {
45541
- screenColumn += 1;
45542
- var span = this.dom.createElement("span");
45543
- span.style.width = (self.config.characterWidth * 2) + "px";
45544
- span.className = "ace_cjk";
45545
- span.textContent = cjk;
45546
- valueFragment.appendChild(span);
45448
+ }
45449
+ var trimmedValue = i ? value.slice(i) : value;
45450
+ if (trimmedValue.length > 256) {
45451
+ for (var j = 0; j < trimmedValue.length;) {
45452
+ valueFragment.appendChild(this.dom.createTextNode(trimmedValue.slice(j, j += 256), this.element));
45547
45453
  }
45548
45454
  }
45549
- valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element));
45455
+ else {
45456
+ valueFragment.appendChild(this.dom.createTextNode(trimmedValue, this.element));
45457
+ }
45550
45458
  if (!isTextToken(token.type)) {
45551
45459
  var classes = "ace_" + token.type.replace(/\./g, " ace_");
45552
45460
  var span = this.dom.createElement("span");
@@ -45867,6 +45775,7 @@ Text.prototype.EOL_CHAR_CRLF = "\xa4";
45867
45775
  Text.prototype.EOL_CHAR = Text.prototype.EOL_CHAR_LF;
45868
45776
  Text.prototype.TAB_CHAR = "\u2014"; //"\u21E5";
45869
45777
  Text.prototype.SPACE_CHAR = "\xB7";
45778
+ Text.prototype.CJK_SPACE_CHAR = "\u30FB";
45870
45779
  Text.prototype.$padding = 0;
45871
45780
  Text.prototype.MAX_LINE_LENGTH = 10000;
45872
45781
  Text.prototype.showInvisibles = false;
@@ -46009,16 +45918,16 @@ var Cursor = /** @class */ (function () {
46009
45918
  };
46010
45919
  Cursor.prototype.getPixelPosition = function (position, onScreen) {
46011
45920
  if (!this.config || !this.session)
46012
- return { left: 0, top: 0 };
45921
+ return { left: 0, top: 0, width: 0 };
46013
45922
  if (!position)
46014
45923
  position = this.session.selection.getCursor();
46015
45924
  var pos = this.session.documentToScreenPosition(position);
46016
- var cursorLeft = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, position.row)
46017
- ? this.session.$bidiHandler.getPosLeft(pos.column)
46018
- : pos.column * this.config.characterWidth);
45925
+ var textWidth = this.config.fontMetrics.textWidth(pos.row, pos.column);
45926
+ var cursorLeft = this.$padding + textWidth;
46019
45927
  var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
46020
45928
  this.config.lineHeight;
46021
- return { left: cursorLeft, top: cursorTop };
45929
+ var cursorWidth = this.config.fontMetrics.textWidth(pos.row, pos.column + 1) - textWidth;
45930
+ return { left: cursorLeft, top: cursorTop, width: Math.abs(cursorWidth) || this.config.characterWidth };
46022
45931
  };
46023
45932
  Cursor.prototype.isCursorInView = function (pixelPos, config) {
46024
45933
  return pixelPos.top >= 0 && pixelPos.top < config.maxHeight;
@@ -46045,7 +45954,7 @@ var Cursor = /** @class */ (function () {
46045
45954
  else {
46046
45955
  dom.setStyle(style, "display", "block");
46047
45956
  dom.translate(element, pixelPos.left, pixelPos.top);
46048
- dom.setStyle(style, "width", Math.round(config.characterWidth) + "px");
45957
+ dom.setStyle(style, "width", Math.round(pixelPos.width) + "px");
46049
45958
  dom.setStyle(style, "height", config.lineHeight + "px");
46050
45959
  }
46051
45960
  }
@@ -46506,17 +46415,36 @@ exports.RenderLoop = RenderLoop;
46506
46415
 
46507
46416
  });
46508
46417
 
46509
- ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module){var oop = require("../lib/oop");
46418
+ ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module){var __read = (this && this.__read) || function (o, n) {
46419
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
46420
+ if (!m) return o;
46421
+ var i = m.call(o), r, ar = [], e;
46422
+ try {
46423
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
46424
+ }
46425
+ catch (error) { e = { error: error }; }
46426
+ finally {
46427
+ try {
46428
+ if (r && !r.done && (m = i["return"])) m.call(i);
46429
+ }
46430
+ finally { if (e) throw e.error; }
46431
+ }
46432
+ return ar;
46433
+ };
46434
+ var oop = require("../lib/oop");
46510
46435
  var dom = require("../lib/dom");
46511
46436
  var lang = require("../lib/lang");
46512
46437
  var event = require("../lib/event");
46513
- var useragent = require("../lib/useragent");
46514
46438
  var EventEmitter = require("../lib/event_emitter").EventEmitter;
46515
46439
  var CHAR_COUNT = 512;
46516
46440
  var USE_OBSERVER = typeof ResizeObserver == "function";
46517
46441
  var L = 200;
46518
46442
  var FontMetrics = /** @class */ (function () {
46519
- function FontMetrics(parentEl) {
46443
+ function FontMetrics(parentEl, textLayer, renderer) {
46444
+ this.config = { characterWidth: 1 };
46445
+ this.$characterSize = { width: 0, height: 0 };
46446
+ this.textLayer = textLayer;
46447
+ this.renderer = renderer;
46520
46448
  this.el = dom.createElement("div");
46521
46449
  this.$setMeasureNodeStyles(this.el.style, true);
46522
46450
  this.$main = dom.createElement("div");
@@ -46527,11 +46455,12 @@ var FontMetrics = /** @class */ (function () {
46527
46455
  this.el.appendChild(this.$measureNode);
46528
46456
  parentEl.appendChild(this.el);
46529
46457
  this.$measureNode.textContent = lang.stringRepeat("X", CHAR_COUNT);
46530
- this.$characterSize = { width: 0, height: 0 };
46531
46458
  if (USE_OBSERVER)
46532
46459
  this.$addObserver();
46533
46460
  else
46534
46461
  this.checkForSizeChanges();
46462
+ this.textLayer.$setFontMetrics(this);
46463
+ this.$scratchRange = document.createRange();
46535
46464
  }
46536
46465
  FontMetrics.prototype.$setMeasureNodeStyles = function (style, isRoot) {
46537
46466
  style.width = style.height = "auto";
@@ -46539,12 +46468,7 @@ var FontMetrics = /** @class */ (function () {
46539
46468
  style.visibility = "hidden";
46540
46469
  style.position = "absolute";
46541
46470
  style.whiteSpace = "pre";
46542
- if (useragent.isIE < 8) {
46543
- style["font-family"] = "inherit";
46544
- }
46545
- else {
46546
- style.font = "inherit";
46547
- }
46471
+ style.font = "inherit";
46548
46472
  style.overflow = isRoot ? "hidden" : "visible";
46549
46473
  };
46550
46474
  FontMetrics.prototype.checkForSizeChanges = function (size) {
@@ -46606,6 +46530,12 @@ var FontMetrics = /** @class */ (function () {
46606
46530
  }
46607
46531
  return w;
46608
46532
  };
46533
+ FontMetrics.prototype.getTextWidth = function (text) {
46534
+ if (!text)
46535
+ return 0;
46536
+ this.$main.textContent = text;
46537
+ return this.$main.clientWidth;
46538
+ };
46609
46539
  FontMetrics.prototype.destroy = function () {
46610
46540
  clearInterval(this.$pollSizeChangesTimer);
46611
46541
  if (this.$observer)
@@ -46613,34 +46543,18 @@ var FontMetrics = /** @class */ (function () {
46613
46543
  if (this.el && this.el.parentNode)
46614
46544
  this.el.parentNode.removeChild(this.el);
46615
46545
  };
46616
- FontMetrics.prototype.$getZoom = function (element) {
46617
- if (!element || !element.parentElement)
46618
- return 1;
46619
- return (Number(window.getComputedStyle(element)["zoom"]) || 1) * this.$getZoom(element.parentElement);
46620
- };
46621
46546
  FontMetrics.prototype.$initTransformMeasureNodes = function () {
46622
- var t = function (t, l) {
46547
+ var t = function (l, t) {
46623
46548
  return ["div", {
46624
- style: "position: absolute;top:" + t + "px;left:" + l + "px;"
46549
+ style: "position: absolute;left:" + l + "px;top:" + t + "px;"
46625
46550
  }];
46626
46551
  };
46627
46552
  this.els = dom.buildDom([t(0, 0), t(L, 0), t(0, L), t(L, L)], this.el);
46628
46553
  };
46629
- FontMetrics.prototype.transformCoordinates = function (clientPos, elPos) {
46630
- if (clientPos) {
46631
- var zoom = this.$getZoom(this.el);
46632
- clientPos = mul(1 / zoom, clientPos);
46554
+ FontMetrics.prototype.getTransform = function () {
46555
+ if (this.config.$transformData) {
46556
+ return this.config.$transformData;
46633
46557
  }
46634
- function solve(l1, l2, r) {
46635
- var det = l1[1] * l2[0] - l1[0] * l2[1];
46636
- return [
46637
- (-l2[1] * r[0] + l2[0] * r[1]) / det,
46638
- (+l1[1] * r[0] - l1[0] * r[1]) / det
46639
- ];
46640
- }
46641
- function sub(a, b) { return [a[0] - b[0], a[1] - b[1]]; }
46642
- function add(a, b) { return [a[0] + b[0], a[1] + b[1]]; }
46643
- function mul(a, b) { return [a * b[0], a * b[1]]; }
46644
46558
  if (!this.els)
46645
46559
  this.$initTransformMeasureNodes();
46646
46560
  function p(el) {
@@ -46652,23 +46566,400 @@ var FontMetrics = /** @class */ (function () {
46652
46566
  var c = p(this.els[2]);
46653
46567
  var d = p(this.els[3]);
46654
46568
  var h = solve(sub(d, b), sub(d, c), sub(add(b, c), add(d, a)));
46655
- var m1 = mul(1 + h[0], sub(b, a));
46656
- var m2 = mul(1 + h[1], sub(c, a));
46569
+ var m1 = mul((1 + h[0]) / L, sub(b, a));
46570
+ var m2 = mul((1 + h[1]) / L, sub(c, a));
46571
+ var M = [
46572
+ m1[0], m2[0], 0,
46573
+ m1[1], m2[1], 0,
46574
+ h[0] / L, h[1] / L, 1
46575
+ ];
46576
+ var detM = 1 / (M[0] * M[4] - M[3] * M[1]);
46577
+ var MInv = [
46578
+ M[4] * detM, -M[1] * detM, 0,
46579
+ -M[3] * detM, M[0] * detM, 0,
46580
+ (M[3] * M[7] - M[4] * M[6]) * detM, (M[1] * M[6] - M[0] * M[7]) * detM, 1
46581
+ ];
46582
+ this.config.$transformData = {
46583
+ M: M,
46584
+ MInv: MInv,
46585
+ t: a
46586
+ };
46587
+ return this.config.$transformData;
46588
+ };
46589
+ FontMetrics.prototype.transformCoordinates = function (clientPos, elPos) {
46590
+ if (!this.config.$transformData)
46591
+ this.getTransform();
46592
+ var tr = this.config.$transformData;
46657
46593
  if (elPos) {
46658
- var x = elPos;
46659
- var k = h[0] * x[0] / L + h[1] * x[1] / L + 1;
46660
- var ut = add(mul(x[0], m1), mul(x[1], m2));
46661
- return add(mul(1 / k / L, ut), a);
46594
+ return add(project(tr.M, elPos[0], elPos[1]), tr.t);
46595
+ }
46596
+ return project(tr.MInv, clientPos[0] - tr.t[0], clientPos[1] - tr.t[1]);
46597
+ };
46598
+ FontMetrics.prototype.recoverRect = function (transform, bbox) {
46599
+ var M = transform.M;
46600
+ var isAffine = Math.abs(M[6]) < 1e-10 && Math.abs(M[7]) < 1e-10;
46601
+ var left = bbox.left, top = bbox.top, Wt = bbox.width, Ht = bbox.height;
46602
+ left -= transform.t[0];
46603
+ top -= transform.t[1];
46604
+ if (isAffine) {
46605
+ var _a = __read(M, 6), m00 = _a[0], m01 = _a[1], m02 = _a[2], m10 = _a[3], m11 = _a[4], m12 = _a[5];
46606
+ var absM = [Math.abs(m00), Math.abs(m01), Math.abs(m10), Math.abs(m11)];
46607
+ var delta = absM[0] * absM[3] - absM[2] * absM[1];
46608
+ var w = void 0, h = void 0;
46609
+ if (Math.abs(delta) < 1e-10) {
46610
+ h = this.config && this.config.lineHeight || 0;
46611
+ w = (Wt - absM[1] * h) / absM[0];
46612
+ }
46613
+ else {
46614
+ w = (absM[3] * Wt - absM[1] * Ht) / delta;
46615
+ h = (-absM[2] * Wt + absM[0] * Ht) / delta;
46616
+ }
46617
+ var detM = m00 * m11 - m01 * m10;
46618
+ var ctx = left + Wt / 2 - m02;
46619
+ var cty = top + Ht / 2 - m12;
46620
+ var cx = (m11 * ctx - m01 * cty) / detM;
46621
+ var cy = (-m10 * ctx + m00 * cty) / detM;
46622
+ return { left: cx - w / 2, top: cy - h / 2, width: w, height: h, right: cx + w / 2, bottom: cy + h / 2 };
46623
+ }
46624
+ return recoverRect(transform, bbox);
46625
+ };
46626
+ FontMetrics.prototype.$findElementForScreenRow = function (screenRow) {
46627
+ var textLayer = this.textLayer;
46628
+ if (!this.config)
46629
+ return null; // not initialized yet
46630
+ var data = textLayer.$lines.$getCellByScreenRow(screenRow, this.config);
46631
+ var lineElement = data && data.cell.element;
46632
+ if (lineElement && textLayer.$useLineGroups()) {
46633
+ var index = Math.floor(data.offset / this.config.lineHeight);
46634
+ lineElement = lineElement.children[Math.max(index, 0)];
46635
+ }
46636
+ return lineElement;
46637
+ };
46638
+ FontMetrics.prototype.textWidth = function (screenRow, screenColumn) {
46639
+ var lineElement = this.$findElementForScreenRow(screenRow);
46640
+ if (!lineElement || !document.createRange) {
46641
+ return screenColumn * this.config.characterWidth;
46642
+ }
46643
+ return this.$measureLineToColumn(lineElement, screenColumn);
46644
+ };
46645
+ FontMetrics.prototype.$measureLineToColumn = function (lineElement, screenColumn) {
46646
+ var textLayer = this.textLayer;
46647
+ try {
46648
+ var position = this.$findColumnPosition(lineElement, screenColumn);
46649
+ if (!position) {
46650
+ return screenColumn * this.config.characterWidth;
46651
+ }
46652
+ this.$scratchRange.setStart(position.node, position.offset);
46653
+ this.$scratchRange.setEnd(position.node, position.offset);
46654
+ var rangeRect = this.$scratchRange.getBoundingClientRect();
46655
+ if (this.renderer.$hasCssTransforms) {
46656
+ var tr = this.getTransform();
46657
+ var transformed = this.recoverRect(tr, rangeRect);
46658
+ var leftOffset = this.renderer.gutterWidth + this.renderer.margin.left + this.renderer.$padding - this.renderer.scrollLeft;
46659
+ return transformed.left - leftOffset + position.overflow * this.config.characterWidth;
46660
+ }
46661
+ var rect = textLayer.element.getBoundingClientRect();
46662
+ return rangeRect.left - rect.left + position.overflow * this.config.characterWidth;
46662
46663
  }
46663
- var u = sub(clientPos, a);
46664
- var f = solve(sub(m1, mul(h[0], u)), sub(m2, mul(h[1], u)), u);
46665
- return mul(L, f);
46664
+ catch (e) {
46665
+ console.error("Error measuring text width:", e);
46666
+ return screenColumn * this.config.characterWidth;
46667
+ }
46668
+ };
46669
+ FontMetrics.prototype.$findColumnPosition = function (lineElement, screenColumn) {
46670
+ var walker = document.createTreeWalker(lineElement, NodeFilter.SHOW_TEXT, null);
46671
+ var currentColumn = 0;
46672
+ var node, lastNode;
46673
+ while (node = walker.nextNode()) {
46674
+ var nodeText = node.nodeValue;
46675
+ var nodeLength = nodeText.length;
46676
+ if (currentColumn + nodeLength >= screenColumn) {
46677
+ return {
46678
+ node: node,
46679
+ offset: screenColumn - currentColumn,
46680
+ overflow: 0
46681
+ };
46682
+ }
46683
+ currentColumn += nodeLength;
46684
+ lastNode = node;
46685
+ }
46686
+ return lastNode && {
46687
+ node: lastNode,
46688
+ offset: lastNode.nodeValue.length,
46689
+ overflow: screenColumn - currentColumn,
46690
+ };
46691
+ };
46692
+ FontMetrics.prototype.$pixelToColumn = function (screenRow, screenColumnMonospace, x, blockCursor, isTextWidthCoordinate) {
46693
+ var _this = this;
46694
+ var scratchRange = this.$scratchRange;
46695
+ var lineElement = this.$findElementForScreenRow(screenRow);
46696
+ if (!lineElement || screenColumnMonospace < 0)
46697
+ return screenColumnMonospace;
46698
+ var hasCssTransform = this.renderer.$hasCssTransforms;
46699
+ var tr = hasCssTransform && this.getTransform();
46700
+ if (isTextWidthCoordinate) {
46701
+ if (!hasCssTransform) {
46702
+ x += this.textLayer.element.getBoundingClientRect().left;
46703
+ }
46704
+ else {
46705
+ x += this.renderer.gutterWidth + this.renderer.margin.left + this.renderer.$padding - this.renderer.scrollLeft;
46706
+ }
46707
+ }
46708
+ var screenColumn = 0;
46709
+ var getRects = function (node) {
46710
+ var rects = [];
46711
+ if (node.nodeType === Node.TEXT_NODE) {
46712
+ scratchRange.setStart(node, 0);
46713
+ scratchRange.setEnd(node, node.nodeValue.length);
46714
+ rects = Array.from(scratchRange.getClientRects());
46715
+ }
46716
+ else if (node.nodeType === Node.ELEMENT_NODE) {
46717
+ rects = Array.from(node.getClientRects());
46718
+ }
46719
+ if (hasCssTransform) {
46720
+ var fixedRects = [];
46721
+ for (var i = 0; i < rects.length; i++) {
46722
+ var rect = rects[i];
46723
+ fixedRects.push(_this.recoverRect(tr, rect));
46724
+ }
46725
+ rects = fixedRects;
46726
+ }
46727
+ return rects;
46728
+ };
46729
+ var self = this;
46730
+ function search(node) {
46731
+ if (node.nodeType === Node.TEXT_NODE) {
46732
+ var textLength = node.nodeValue.length;
46733
+ var maxDistance = Number.MAX_VALUE;
46734
+ var index = -1;
46735
+ var lastSignedDistance = undefined;
46736
+ var value = node.nodeValue;
46737
+ for (var j = 0; j <= textLength; j++) {
46738
+ scratchRange.setStart(node, j);
46739
+ scratchRange.setEnd(node, j);
46740
+ if (j > 0 && j < textLength && /[\uDC00-\uDFFF]/.test(value.charAt(j)) &&
46741
+ /[\uD800-\uDBFF]/.test(value.charAt(j - 1))) {
46742
+ continue;
46743
+ }
46744
+ var rect = /** @type {ReturnType<FontMetrics['recoverRect']>}*/ (scratchRange.getBoundingClientRect());
46745
+ if (hasCssTransform) {
46746
+ rect = self.recoverRect(tr, rect);
46747
+ }
46748
+ var signedDistance = x - rect.left;
46749
+ var d = Math.abs(signedDistance);
46750
+ if (d < maxDistance) {
46751
+ index = j;
46752
+ maxDistance = d;
46753
+ lastSignedDistance = signedDistance;
46754
+ }
46755
+ }
46756
+ if (blockCursor) {
46757
+ if (lastSignedDistance < 0) {
46758
+ index = Math.max(0, index - 1);
46759
+ }
46760
+ }
46761
+ return screenColumn = screenColumn + index;
46762
+ }
46763
+ else if (node.nodeType === Node.ELEMENT_NODE) {
46764
+ var childNodes = node.childNodes;
46765
+ for (var i = 0; i < childNodes.length; i++) {
46766
+ var child = childNodes[i];
46767
+ var rects = getRects(child);
46768
+ for (var j = 0; j < rects.length; j++) {
46769
+ var rect = rects[j];
46770
+ if (rect.left <= x && x <= rect.left + rect.width) {
46771
+ search(child);
46772
+ return screenColumn;
46773
+ }
46774
+ }
46775
+ screenColumn += child.nodeType === Node.TEXT_NODE ? child.nodeValue.length : child.textContent.length;
46776
+ }
46777
+ }
46778
+ }
46779
+ search(lineElement);
46780
+ return screenColumn;
46781
+ };
46782
+ FontMetrics.prototype.getRects = function (startScreenPos, endScreenPos) {
46783
+ var row = startScreenPos.row;
46784
+ var textLayer = this.textLayer;
46785
+ var lineElement = this.$findElementForScreenRow(row);
46786
+ if (lineElement) {
46787
+ try {
46788
+ var p1 = this.$findColumnPosition(lineElement, startScreenPos.column);
46789
+ var p2 = this.$findColumnPosition(lineElement, endScreenPos.column);
46790
+ if (p1 && p2) {
46791
+ this.$scratchRange.setStart(p1.node, p1.offset);
46792
+ this.$scratchRange.setEnd(p2.node, p2.offset);
46793
+ var rangeRects = this.$scratchRange.getClientRects();
46794
+ var hasCssTransform = this.renderer && this.renderer.$hasCssTransforms;
46795
+ if (hasCssTransform) {
46796
+ var tr = this.getTransform();
46797
+ var rects = [];
46798
+ for (var i = 0; i < rangeRects.length; i++) {
46799
+ var rangeRect = this.recoverRect(tr, rangeRects[i]);
46800
+ rangeRect.right = rangeRect.left + rangeRect.width;
46801
+ rects.push(rangeRect);
46802
+ }
46803
+ var leftOffset = this.renderer.gutterWidth + this.renderer.margin.left + this.renderer.$padding - this.renderer.scrollLeft;
46804
+ var merged = mergeTouchingRects(rects).map(function (r) {
46805
+ return {
46806
+ left: r.left - leftOffset,
46807
+ width: r.right - r.left,
46808
+ };
46809
+ });
46810
+ return merged;
46811
+ }
46812
+ var rect = textLayer.element.getBoundingClientRect();
46813
+ var merged = mergeTouchingRects(rangeRects).map(function (r) {
46814
+ return {
46815
+ left: r.left - rect.left,
46816
+ width: r.right - r.left,
46817
+ };
46818
+ });
46819
+ return merged;
46820
+ }
46821
+ }
46822
+ catch (e) {
46823
+ console.error("Error measuring text width:", e);
46824
+ }
46825
+ }
46826
+ return [{
46827
+ left: startScreenPos.column * this.config.characterWidth,
46828
+ width: (endScreenPos.column - startScreenPos.column) * this.config.characterWidth,
46829
+ }];
46666
46830
  };
46667
46831
  return FontMetrics;
46668
46832
  }());
46669
- FontMetrics.prototype.$characterSize = { width: 0, height: 0 };
46833
+ function mergeTouchingRects(rects) {
46834
+ var merged = [];
46835
+ for (var i = 0; i < rects.length; i++) {
46836
+ var rect = rects[i];
46837
+ var found = false;
46838
+ for (var j = 0; j < merged.length; j++) {
46839
+ var m = merged[j];
46840
+ if ((m.left <= rect.left && rect.left <= m.right) ||
46841
+ (m.left <= rect.right && rect.right <= m.right) ||
46842
+ (rect.left <= m.left && m.right <= rect.right)) {
46843
+ m.left = Math.min(m.left, rect.left);
46844
+ m.right = Math.max(m.right, rect.right);
46845
+ found = true;
46846
+ break;
46847
+ }
46848
+ }
46849
+ if (!found) {
46850
+ merged.push({
46851
+ left: rect.left,
46852
+ right: rect.right,
46853
+ top: rect.top,
46854
+ height: rect.height,
46855
+ });
46856
+ }
46857
+ }
46858
+ return merged;
46859
+ }
46860
+ function solve(l1, l2, r) {
46861
+ var det = l1[1] * l2[0] - l1[0] * l2[1];
46862
+ return [
46863
+ (-l2[1] * r[0] + l2[0] * r[1]) / det,
46864
+ (+l1[1] * r[0] - l1[0] * r[1]) / det
46865
+ ];
46866
+ }
46867
+ function sub(a, b) { return [a[0] - b[0], a[1] - b[1]]; }
46868
+ function add(a, b) { return [a[0] + b[0], a[1] + b[1]]; }
46869
+ function mul(a, b) { return [a * b[0], a * b[1]]; }
46670
46870
  oop.implement(FontMetrics.prototype, EventEmitter);
46671
46871
  exports.FontMetrics = FontMetrics;
46872
+ function recoverRect(transform, bbox) {
46873
+ var left = bbox.left, top = bbox.top, width = bbox.width, height = bbox.height;
46874
+ var M = transform.M;
46875
+ left -= transform.t[0];
46876
+ top -= transform.t[1];
46877
+ bbox = { left: left, top: top, width: width, height: height };
46878
+ var targets = [top, left + width, top + height, left]; // minY, maxX, maxY, minX
46879
+ var isYAxis = [true, false, true, false]; // minY=Y, maxX=X, maxY=Y, minX=X
46880
+ var corners = [
46881
+ [0, 0], [1, 0], [1, 1], [0, 1]
46882
+ ];
46883
+ var result = null;
46884
+ var mainMappings = [27, 57, 23, 53, 43, 9, 10, 11, 14, 37, 31, 56, 40, 41, 47];
46885
+ for (var i = -mainMappings.length; i < 256; i++) {
46886
+ var index = i < 0 ? mainMappings[mainMappings.length + i] : i;
46887
+ var mappingIdx = [
46888
+ (index >> 0) & 3,
46889
+ (index >> 2) & 3,
46890
+ (index >> 4) & 3,
46891
+ (index >> 6) & 3
46892
+ ];
46893
+ var mapping = mappingIdx.map(function (idx) { return corners[idx]; });
46894
+ var rows = mapping.map(function (c, j) {
46895
+ var _a = __read(c, 2), dx = _a[0], dy = _a[1];
46896
+ var target = targets[j];
46897
+ var m = isYAxis[j] ? M.slice(3, 6) : M.slice(0, 3);
46898
+ var mp = M.slice(6, 9);
46899
+ var ax = m[0] - target * mp[0];
46900
+ var ay = m[1] - target * mp[1];
46901
+ return [ax, ay, dx * ax, dy * ay, target * mp[2] - m[2]];
46902
+ });
46903
+ var res = solve4x4(rows);
46904
+ var result;
46905
+ if (res) {
46906
+ var _a = __read(res, 4), x0 = _a[0], y0 = _a[1], w = _a[2], h = _a[3];
46907
+ if (w < 0) {
46908
+ x0 += w;
46909
+ w = -w;
46910
+ }
46911
+ if (h < 0) {
46912
+ y0 += h;
46913
+ h = -h;
46914
+ }
46915
+ if (validateSolution(M, x0, y0, w, h, bbox)) {
46916
+ result = { left: x0, top: y0, width: w, height: h, right: x0 + w, bottom: y0 + h, mappingIdx: i };
46917
+ break;
46918
+ }
46919
+ }
46920
+ }
46921
+ if (!result)
46922
+ console.warn("No valid mapping found in 256 combinations.");
46923
+ return result;
46924
+ }
46925
+ var project = function (m, px, py) {
46926
+ var k = m[6] * px + m[7] * py + m[8];
46927
+ return [(m[0] * px + m[1] * py + m[2]) / k, (m[3] * px + m[4] * py + m[5]) / k];
46928
+ };
46929
+ function validateSolution(M, x, y, w, h, targetBbox) {
46930
+ var pts = [
46931
+ [x, y], [x + w, y], [x + w, y + h], [x, y + h]
46932
+ ];
46933
+ return pts.every(function (p) {
46934
+ var mapped = project(M, p[0], p[1]);
46935
+ return targetBbox.left - 0.5 <= mapped[0] && mapped[0] <= targetBbox.left + targetBbox.width + 0.5
46936
+ && targetBbox.top - 0.5 <= mapped[1] && mapped[1] <= targetBbox.top + targetBbox.height + 0.5;
46937
+ });
46938
+ }
46939
+ function solve4x4(m) {
46940
+ var _a;
46941
+ var n = 4;
46942
+ for (var i = 0; i < n; i++) {
46943
+ var max = i;
46944
+ for (var j = i + 1; j < n; j++)
46945
+ if (Math.abs(m[j][i]) > Math.abs(m[max][i]))
46946
+ max = j;
46947
+ _a = __read([m[max], m[i]], 2), m[i] = _a[0], m[max] = _a[1];
46948
+ var p = m[i][i];
46949
+ if (Math.abs(p) < 1e-10)
46950
+ return null;
46951
+ for (var j = i; j <= n; j++)
46952
+ m[i][j] /= p;
46953
+ for (var k = 0; k < n; k++) {
46954
+ if (k !== i) {
46955
+ var f = m[k][i];
46956
+ for (var j = i; j <= n; j++)
46957
+ m[k][j] -= f * m[i][j];
46958
+ }
46959
+ }
46960
+ }
46961
+ return m.map(function (row) { return row[n]; });
46962
+ }
46672
46963
 
46673
46964
  });
46674
46965
 
@@ -46883,8 +47174,7 @@ var VirtualRenderer = /** @class */ (function () {
46883
47174
  row: 0,
46884
47175
  column: 0
46885
47176
  };
46886
- this.$fontMetrics = new FontMetrics(this.container);
46887
- this.$textLayer.$setFontMetrics(this.$fontMetrics);
47177
+ this.$fontMetrics = new FontMetrics(this.container, this.$textLayer, this);
46888
47178
  this.$textLayer.on("changeCharacterSize", function (e) {
46889
47179
  _self.updateCharacterSize();
46890
47180
  _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
@@ -46905,12 +47195,14 @@ var VirtualRenderer = /** @class */ (function () {
46905
47195
  lastRow: 0,
46906
47196
  lineHeight: 0,
46907
47197
  characterWidth: 0,
47198
+ fontMetrics: this.$fontMetrics,
46908
47199
  minHeight: 1,
46909
47200
  maxHeight: 1,
46910
47201
  offset: 0,
46911
47202
  height: 1,
46912
47203
  gutterOffset: 1
46913
47204
  };
47205
+ this.$fontMetrics.config = this.layerConfig;
46914
47206
  this.scrollMargin = {
46915
47207
  left: 0,
46916
47208
  right: 0,
@@ -47231,7 +47523,7 @@ var VirtualRenderer = /** @class */ (function () {
47231
47523
  else {
47232
47524
  if (composition.useTextareaForIME) {
47233
47525
  var val = this.textarea.value;
47234
- w = this.characterWidth * (this.session.$getStringScreenWidth(val)[0]);
47526
+ w = this.$fontMetrics.getTextWidth(val) + 1;
47235
47527
  }
47236
47528
  else {
47237
47529
  posTop += this.lineHeight + 2;
@@ -47346,8 +47638,6 @@ var VirtualRenderer = /** @class */ (function () {
47346
47638
  this.$textLayer.checkForSizeChanges();
47347
47639
  }
47348
47640
  this._signal("beforeRender", changes);
47349
- if (this.session && this.session.$bidiHandler)
47350
- this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics);
47351
47641
  var config = this.layerConfig;
47352
47642
  if (changes & this.CHANGE_FULL ||
47353
47643
  changes & this.CHANGE_SIZE ||
@@ -47365,17 +47655,9 @@ var VirtualRenderer = /** @class */ (function () {
47365
47655
  }
47366
47656
  }
47367
47657
  config = this.layerConfig;
47368
- this.$updateScrollBarV();
47369
- if (changes & this.CHANGE_H_SCROLL)
47370
- this.$updateScrollBarH();
47371
- dom.translate(this.content, -this.scrollLeft, -config.offset);
47372
- var width = config.width + 2 * this.$padding + "px";
47373
- var height = config.minHeight + "px";
47374
- dom.setStyle(this.content.style, "width", width);
47375
- dom.setStyle(this.content.style, "height", height);
47376
47658
  }
47377
47659
  if (changes & this.CHANGE_H_SCROLL) {
47378
- dom.translate(this.content, -this.scrollLeft, -config.offset);
47660
+ this.$updateContentTransformAndSize(config, changes);
47379
47661
  this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller " : "ace_scroller ace_scroll-left ";
47380
47662
  if (this.enableKeyboardAccessibility)
47381
47663
  this.scroller.className += this.keyboardFocusClassName;
@@ -47391,6 +47673,7 @@ var VirtualRenderer = /** @class */ (function () {
47391
47673
  this.$markerBack.update(config);
47392
47674
  this.$markerFront.update(config);
47393
47675
  this.$cursorLayer.update(config);
47676
+ this.$updateContentTransformAndSize(config, changes);
47394
47677
  this.$moveTextAreaToCursor();
47395
47678
  this._signal("afterRender", changes);
47396
47679
  return;
@@ -47413,6 +47696,7 @@ var VirtualRenderer = /** @class */ (function () {
47413
47696
  this.$markerBack.update(config);
47414
47697
  this.$markerFront.update(config);
47415
47698
  this.$cursorLayer.update(config);
47699
+ this.$updateContentTransformAndSize(config, changes);
47416
47700
  this.$moveTextAreaToCursor();
47417
47701
  this._signal("afterRender", changes);
47418
47702
  return;
@@ -47425,6 +47709,7 @@ var VirtualRenderer = /** @class */ (function () {
47425
47709
  if (this.$customScrollbar) {
47426
47710
  this.$scrollDecorator.$updateDecorators(config);
47427
47711
  }
47712
+ this.$updateContentTransformAndSize(config, changes);
47428
47713
  }
47429
47714
  else if (changes & this.CHANGE_LINES) {
47430
47715
  if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
@@ -47482,6 +47767,44 @@ var VirtualRenderer = /** @class */ (function () {
47482
47767
  this._signal("autosize");
47483
47768
  }
47484
47769
  };
47770
+ VirtualRenderer.prototype.$updateContentTransformAndSize = function (config, changes) {
47771
+ var sm = this.scrollMargin;
47772
+ if (this.session && !this.session.getUseWrapMode()) {
47773
+ var longestRendered = this.$getLongestRenderedLine();
47774
+ if (config.width < longestRendered) {
47775
+ config.width = longestRendered;
47776
+ }
47777
+ }
47778
+ if (this.session) {
47779
+ this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft, config.width + 2 * this.$padding - this.$size.scrollerWidth + sm.right)));
47780
+ }
47781
+ dom.translate(this.content, -this.scrollLeft, -config.offset);
47782
+ var width = config.width + 2 * this.$padding + "px";
47783
+ var height = config.minHeight + "px";
47784
+ dom.setStyle(this.content.style, "width", width);
47785
+ dom.setStyle(this.content.style, "height", height);
47786
+ this.$updateScrollBarV();
47787
+ if (changes & this.CHANGE_H_SCROLL)
47788
+ this.$updateScrollBarH();
47789
+ };
47790
+ VirtualRenderer.prototype.$getLongestRenderedLine = function () {
47791
+ var max = 0;
47792
+ var transform = this.$hasCssTransforms && this.$fontMetrics.getTransform();
47793
+ var cells = this.$textLayer.$lines.cells;
47794
+ for (var i = 0; i < cells.length; i++) {
47795
+ var lineElement = cells[i].element;
47796
+ this.$fontMetrics.$scratchRange.setStart(lineElement, 0);
47797
+ this.$fontMetrics.$scratchRange.setEnd(lineElement, lineElement.childNodes.length);
47798
+ var rect = /** @type {ReturnType<FontMetrics['recoverRect']>}*/ (this.$fontMetrics.$scratchRange.getBoundingClientRect());
47799
+ if (this.$hasCssTransforms) {
47800
+ rect = this.$fontMetrics.recoverRect(transform, rect) || rect;
47801
+ }
47802
+ var w = rect.width;
47803
+ if (w > max)
47804
+ max = w;
47805
+ }
47806
+ return max;
47807
+ };
47485
47808
  VirtualRenderer.prototype.$computeLayerConfig = function () {
47486
47809
  var session = this.session;
47487
47810
  var size = this.$size;
@@ -47508,7 +47831,6 @@ var VirtualRenderer = /** @class */ (function () {
47508
47831
  maxHeight += scrollPastEnd;
47509
47832
  var sm = this.scrollMargin;
47510
47833
  this.session.setScrollTop(Math.max(-sm.top, Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
47511
- this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft, longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
47512
47834
  var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
47513
47835
  size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
47514
47836
  var vScrollChanged = vScrollBefore !== vScroll;
@@ -47554,12 +47876,14 @@ var VirtualRenderer = /** @class */ (function () {
47554
47876
  lastRow: lastRow,
47555
47877
  lineHeight: lineHeight,
47556
47878
  characterWidth: this.characterWidth,
47879
+ fontMetrics: this.$fontMetrics,
47557
47880
  minHeight: minHeight,
47558
47881
  maxHeight: maxHeight,
47559
47882
  offset: offset,
47560
47883
  gutterOffset: lineHeight ? Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)) : 0,
47561
47884
  height: this.$size.scrollerHeight
47562
47885
  };
47886
+ this.$fontMetrics.config = this.layerConfig;
47563
47887
  if (this.session.$bidiHandler)
47564
47888
  this.session.$bidiHandler.setContentWidth(longestLine - this.$padding);
47565
47889
  return changes;
@@ -47798,44 +48122,40 @@ var VirtualRenderer = /** @class */ (function () {
47798
48122
  VirtualRenderer.prototype.pixelToScreenCoordinates = function (x, y) {
47799
48123
  var canvasPos;
47800
48124
  if (this.$hasCssTransforms) {
47801
- canvasPos = { top: 0, left: 0 };
48125
+ canvasPos = { top: this.margin.top, left: this.gutterWidth + this.margin.left };
47802
48126
  var p = this.$fontMetrics.transformCoordinates([x, y]);
47803
- x = p[1] - this.gutterWidth - this.margin.left;
47804
- y = p[0];
48127
+ x = p[0];
48128
+ y = p[1];
47805
48129
  }
47806
48130
  else {
47807
48131
  canvasPos = this.scroller.getBoundingClientRect();
47808
48132
  }
47809
48133
  var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding;
47810
48134
  var offset = offsetX / this.characterWidth;
47811
- var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
48135
+ var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
47812
48136
  var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset);
48137
+ col = this.$fontMetrics.$pixelToColumn(row, col, x, this.$blockCursor);
47813
48138
  return { row: row, column: col, side: offset - col > 0 ? 1 : -1, offsetX: offsetX };
47814
48139
  };
47815
48140
  VirtualRenderer.prototype.screenToTextCoordinates = function (x, y) {
47816
- var canvasPos;
47817
- if (this.$hasCssTransforms) {
47818
- canvasPos = { top: 0, left: 0 };
47819
- var p = this.$fontMetrics.transformCoordinates([x, y]);
47820
- x = p[1] - this.gutterWidth - this.margin.left;
47821
- y = p[0];
47822
- }
47823
- else {
47824
- canvasPos = this.scroller.getBoundingClientRect();
47825
- }
47826
- var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding;
47827
- var offset = offsetX / this.characterWidth;
47828
- var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset);
47829
- var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
47830
- return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX);
48141
+ var screenPos = this.pixelToScreenCoordinates(x, y);
48142
+ return this.session.screenToDocumentPosition(screenPos.row, Math.max(screenPos.column, 0));
47831
48143
  };
47832
48144
  VirtualRenderer.prototype.textToScreenCoordinates = function (row, column) {
47833
- var canvasPos = this.scroller.getBoundingClientRect();
47834
48145
  var pos = this.session.documentToScreenPosition(row, column);
47835
- var x = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, row)
47836
- ? this.session.$bidiHandler.getPosLeft(pos.column)
47837
- : Math.round(pos.column * this.characterWidth));
48146
+ var x = this.$padding + this.$fontMetrics.textWidth(pos.row, pos.column);
47838
48147
  var y = pos.row * this.lineHeight;
48148
+ if (this.$hasCssTransforms) {
48149
+ var pagePos = this.$fontMetrics.transformCoordinates(null, [
48150
+ this.gutterWidth + this.margin.left + x - this.scrollLeft,
48151
+ this.margin.top + y - this.scrollTop
48152
+ ]);
48153
+ return {
48154
+ pageX: pagePos[0],
48155
+ pageY: pagePos[1]
48156
+ };
48157
+ }
48158
+ var canvasPos = this.scroller.getBoundingClientRect();
47839
48159
  return {
47840
48160
  pageX: canvasPos.left + x - this.scrollLeft,
47841
48161
  pageY: canvasPos.top + y - this.scrollTop
@@ -48852,7 +49172,7 @@ function onMouseDown(e) {
48852
49172
  var rectSel = [];
48853
49173
  var blockSelect = function () {
48854
49174
  var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
48855
- var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column, newCursor.offsetX);
49175
+ var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
48856
49176
  if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
48857
49177
  return;
48858
49178
  screenCursor = newCursor;
@@ -49098,7 +49418,8 @@ var EditSession = require("./edit_session").EditSession;
49098
49418
  }
49099
49419
  for (var i = removed.length; i--;) {
49100
49420
  var index = this.ranges.indexOf(removed[i]);
49101
- this.ranges.splice(index, 1);
49421
+ if (index != -1)
49422
+ this.ranges.splice(index, 1);
49102
49423
  }
49103
49424
  this._signal("removeRange", { ranges: removed });
49104
49425
  if (this.rangeCount === 0 && this.inMultiSelectMode) {
@@ -49172,14 +49493,10 @@ var EditSession = require("./edit_session").EditSession;
49172
49493
  if (xBackwards) {
49173
49494
  var startColumn = screenCursor.column;
49174
49495
  var endColumn = screenAnchor.column;
49175
- var startOffsetX = screenCursor.offsetX;
49176
- var endOffsetX = screenAnchor.offsetX;
49177
49496
  }
49178
49497
  else {
49179
49498
  var startColumn = screenAnchor.column;
49180
49499
  var endColumn = screenCursor.column;
49181
- var startOffsetX = screenAnchor.offsetX;
49182
- var endOffsetX = screenCursor.offsetX;
49183
49500
  }
49184
49501
  var yBackwards = screenCursor.row < screenAnchor.row;
49185
49502
  if (yBackwards) {
@@ -49198,7 +49515,7 @@ var EditSession = require("./edit_session").EditSession;
49198
49515
  includeEmptyLines = true;
49199
49516
  var docEnd;
49200
49517
  for (var row = startRow; row <= endRow; row++) {
49201
- var range = Range.fromPoints(this.session.screenToDocumentPosition(row, startColumn, startOffsetX), this.session.screenToDocumentPosition(row, endColumn, endOffsetX));
49518
+ var range = Range.fromPoints(this.session.screenToDocumentPosition(row, startColumn), this.session.screenToDocumentPosition(row, endColumn));
49202
49519
  if (range.isEmpty()) {
49203
49520
  if (docEnd && isSamePoint(range.end, docEnd))
49204
49521
  break;
@@ -49335,32 +49652,36 @@ var Editor = require("./editor").Editor;
49335
49652
  selection._eventRegistry = {};
49336
49653
  var tmpSel = new Selection(session);
49337
49654
  this.inVirtualSelectionMode = true;
49338
- for (var i = ranges.length; i--;) {
49339
- if ($byLines) {
49340
- while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
49341
- i--;
49655
+ try {
49656
+ for (var i = ranges.length; i--;) {
49657
+ if ($byLines) {
49658
+ while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
49659
+ i--;
49660
+ }
49661
+ tmpSel.fromOrientedRange(ranges[i]);
49662
+ tmpSel.index = i;
49663
+ this.selection = session.selection = tmpSel;
49664
+ var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
49665
+ if (!result && cmdResult !== undefined)
49666
+ result = cmdResult;
49667
+ tmpSel.toOrientedRange(ranges[i]);
49342
49668
  }
49343
- tmpSel.fromOrientedRange(ranges[i]);
49344
- tmpSel.index = i;
49345
- this.selection = session.selection = tmpSel;
49346
- var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
49347
- if (!result && cmdResult !== undefined)
49348
- result = cmdResult;
49349
- tmpSel.toOrientedRange(ranges[i]);
49350
- }
49351
- tmpSel.detach();
49352
- this.selection = session.selection = selection;
49353
- this.inVirtualSelectionMode = false;
49354
- selection._eventRegistry = reg;
49355
- selection.mergeOverlappingRanges();
49356
- if (selection.ranges[0])
49357
- selection.fromOrientedRange(selection.ranges[0]);
49358
- var anim = this.renderer.$scrollAnimation;
49359
- this.onCursorChange();
49360
- this.onSelectionChange();
49361
- if (anim && anim.from == anim.to)
49362
- this.renderer.animateScrolling(anim.from);
49363
- return result;
49669
+ tmpSel.detach();
49670
+ }
49671
+ finally {
49672
+ this.selection = session.selection = selection;
49673
+ this.inVirtualSelectionMode = false;
49674
+ selection._eventRegistry = reg;
49675
+ selection.mergeOverlappingRanges();
49676
+ if (selection.ranges[0])
49677
+ selection.fromOrientedRange(selection.ranges[0]);
49678
+ var anim = this.renderer.$scrollAnimation;
49679
+ this.onCursorChange();
49680
+ this.onSelectionChange();
49681
+ if (anim && anim.from == anim.to)
49682
+ this.renderer.animateScrolling(anim.from);
49683
+ return result;
49684
+ }
49364
49685
  };
49365
49686
  this.exitMultiSelectMode = function () {
49366
49687
  if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
@@ -49388,6 +49709,8 @@ var Editor = require("./editor").Editor;
49388
49709
  this.$checkMultiselectChange = function (e, anchor) {
49389
49710
  if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
49390
49711
  var range = this.multiSelect.ranges[0];
49712
+ if (!range)
49713
+ return;
49391
49714
  if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
49392
49715
  return;
49393
49716
  var pos = anchor == this.multiSelect.anchor
@@ -51009,7 +51332,8 @@ function is(token, type) {
51009
51332
  }
51010
51333
  var tags = session.getMatchingTags({ row: row, column: 0 });
51011
51334
  if (tags) {
51012
- return new Range(tags.openTag.end.row, tags.openTag.end.column, tags.closeTag.start.row, tags.closeTag.start.column);
51335
+ var startRow = tags.openTag.start.row;
51336
+ return new Range(startRow, session.getLine(startRow).length, tags.closeTag.start.row, tags.closeTag.start.column);
51013
51337
  }
51014
51338
  };
51015
51339
  }).call(FoldMode.prototype);
@@ -66807,7 +67131,7 @@ var src_default = VueToastificationPlugin;
66807
67131
  (module) {
66808
67132
 
66809
67133
  "use strict";
66810
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@mongoosejs/studio","version":"0.7.0","description":"AI-Powered Data Workspace for MongoDB: Turn your MongoDB data into dashboards, maps, and interactive workflows - powered by your Mongoose models and AI.","homepage":"https://mongoosestudio.app/","repository":{"type":"git","url":"https://github.com/mongoosejs/studio"},"license":"Apache-2.0","dependencies":{"@ai-sdk/anthropic":"2.x","@ai-sdk/google":"2.x","@ai-sdk/openai":"2.x","@modelcontextprotocol/sdk":"^1.30.1","ace-builds":"^1.43.6","ai":"5.x","archetype":"0.13.1","csv-stringify":"6.3.0","ejson":"^2.2.3","extrovert":"^0.2.1","marked":"15.0.12","mpath":"^0.9.0","node-inspect-extracted":"3.x","regexp.escape":"^2.0.1","tailwindcss":"3.4.0","time-commando":"1.0.1","typescript":"^6.0.2","vue":"3.x","vue-toastification":"^2.0.0-rc.5","webpack":"5.x","xss":"^1.0.15","zod":"^4.6.5"},"peerDependencies":{"@nestjs/common":"10.x || 11.x","mongoose":"7.x || 8.x || ^9.0.0"},"peerDependenciesMeta":{"@nestjs/common":{"optional":true}},"optionalPeerDependencies":{"@mongoosejs/task":"0.5.x || 0.6.x"},"devDependencies":{"@masteringjs/eslint-config":"0.1.1","axios":"1.2.2","dedent":"^1.6.0","eslint":"9.30.0","@nestjs/common":"^11.1.9","express":"4.x","mocha":"10.2.0","mongodb-memory-server":"^11.0.1","mongoose":"9.x","sinon":"^21.0.1"},"scripts":{"lint":"eslint .","seed":"node seed/index.js","start":"node ./local.js","tailwind":"tailwindcss -o ./frontend/public/tw.css","tailwind:watch":"tailwindcss -o ./frontend/public/tw.css --watch","test":"mocha test/*.test.js","test:frontend":"mocha test/frontend/*.test.js","eval:agent":"node eval/agent/run.js"}}');
67134
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@mongoosejs/studio","version":"0.7.1","description":"AI-Powered Data Workspace for MongoDB: Turn your MongoDB data into dashboards, maps, and interactive workflows - powered by your Mongoose models and AI.","homepage":"https://mongoosestudio.app/","repository":{"type":"git","url":"https://github.com/mongoosejs/studio"},"license":"Apache-2.0","dependencies":{"@ai-sdk/anthropic":"2.x","@ai-sdk/google":"2.x","@ai-sdk/openai":"2.x","@modelcontextprotocol/sdk":"^1.30.1","ace-builds":"^1.43.6","ai":"5.x","archetype":"0.13.1","csv-stringify":"6.3.0","ejson":"^2.2.3","extrovert":"^0.2.1","marked":"15.0.12","mpath":"^0.9.0","node-inspect-extracted":"3.x","regexp.escape":"^2.0.1","tailwindcss":"3.4.0","time-commando":"1.0.1","typescript":"^6.0.2","vue":"3.x","vue-toastification":"^2.0.0-rc.5","webpack":"5.x","xss":"^1.0.15","zod":"^4.6.5"},"peerDependencies":{"@nestjs/common":"10.x || 11.x","mongoose":"7.x || 8.x || ^9.0.0"},"peerDependenciesMeta":{"@nestjs/common":{"optional":true}},"optionalPeerDependencies":{"@mongoosejs/task":"0.5.x || 0.6.x"},"devDependencies":{"@masteringjs/eslint-config":"0.1.1","axios":"1.2.2","dedent":"^1.6.0","eslint":"9.30.0","@nestjs/common":"^11.1.9","express":"4.x","mocha":"10.2.0","mongodb-memory-server":"^11.0.1","mongoose":"9.x","sinon":"^21.0.1"},"scripts":{"lint":"eslint .","seed":"node seed/index.js","start":"node ./local.js","tailwind":"tailwindcss -o ./frontend/public/tw.css","tailwind:watch":"tailwindcss -o ./frontend/public/tw.css --watch","test":"mocha test/*.test.js","test:frontend":"mocha test/frontend/*.test.js","eval:agent":"node eval/agent/run.js"}}');
66811
67135
 
66812
67136
  /***/ }
66813
67137