model.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. import { equals } from '../../base/common/objects.js';
  6. /**
  7. * Vertical Lane in the overview ruler of the editor.
  8. */
  9. export var OverviewRulerLane;
  10. (function (OverviewRulerLane) {
  11. OverviewRulerLane[OverviewRulerLane["Left"] = 1] = "Left";
  12. OverviewRulerLane[OverviewRulerLane["Center"] = 2] = "Center";
  13. OverviewRulerLane[OverviewRulerLane["Right"] = 4] = "Right";
  14. OverviewRulerLane[OverviewRulerLane["Full"] = 7] = "Full";
  15. })(OverviewRulerLane || (OverviewRulerLane = {}));
  16. /**
  17. * Position in the minimap to render the decoration.
  18. */
  19. export var MinimapPosition;
  20. (function (MinimapPosition) {
  21. MinimapPosition[MinimapPosition["Inline"] = 1] = "Inline";
  22. MinimapPosition[MinimapPosition["Gutter"] = 2] = "Gutter";
  23. })(MinimapPosition || (MinimapPosition = {}));
  24. export var InjectedTextCursorStops;
  25. (function (InjectedTextCursorStops) {
  26. InjectedTextCursorStops[InjectedTextCursorStops["Both"] = 0] = "Both";
  27. InjectedTextCursorStops[InjectedTextCursorStops["Right"] = 1] = "Right";
  28. InjectedTextCursorStops[InjectedTextCursorStops["Left"] = 2] = "Left";
  29. InjectedTextCursorStops[InjectedTextCursorStops["None"] = 3] = "None";
  30. })(InjectedTextCursorStops || (InjectedTextCursorStops = {}));
  31. export class TextModelResolvedOptions {
  32. /**
  33. * @internal
  34. */
  35. constructor(src) {
  36. this._textModelResolvedOptionsBrand = undefined;
  37. this.tabSize = Math.max(1, src.tabSize | 0);
  38. this.indentSize = src.tabSize | 0;
  39. this.insertSpaces = Boolean(src.insertSpaces);
  40. this.defaultEOL = src.defaultEOL | 0;
  41. this.trimAutoWhitespace = Boolean(src.trimAutoWhitespace);
  42. this.bracketPairColorizationOptions = src.bracketPairColorizationOptions;
  43. }
  44. /**
  45. * @internal
  46. */
  47. equals(other) {
  48. return (this.tabSize === other.tabSize
  49. && this.indentSize === other.indentSize
  50. && this.insertSpaces === other.insertSpaces
  51. && this.defaultEOL === other.defaultEOL
  52. && this.trimAutoWhitespace === other.trimAutoWhitespace
  53. && equals(this.bracketPairColorizationOptions, other.bracketPairColorizationOptions));
  54. }
  55. /**
  56. * @internal
  57. */
  58. createChangeEvent(newOpts) {
  59. return {
  60. tabSize: this.tabSize !== newOpts.tabSize,
  61. indentSize: this.indentSize !== newOpts.indentSize,
  62. insertSpaces: this.insertSpaces !== newOpts.insertSpaces,
  63. trimAutoWhitespace: this.trimAutoWhitespace !== newOpts.trimAutoWhitespace,
  64. };
  65. }
  66. }
  67. export class FindMatch {
  68. /**
  69. * @internal
  70. */
  71. constructor(range, matches) {
  72. this._findMatchBrand = undefined;
  73. this.range = range;
  74. this.matches = matches;
  75. }
  76. }
  77. /**
  78. * @internal
  79. */
  80. export function isITextSnapshot(obj) {
  81. return (obj && typeof obj.read === 'function');
  82. }
  83. /**
  84. * @internal
  85. */
  86. export class ValidAnnotatedEditOperation {
  87. constructor(identifier, range, text, forceMoveMarkers, isAutoWhitespaceEdit, _isTracked) {
  88. this.identifier = identifier;
  89. this.range = range;
  90. this.text = text;
  91. this.forceMoveMarkers = forceMoveMarkers;
  92. this.isAutoWhitespaceEdit = isAutoWhitespaceEdit;
  93. this._isTracked = _isTracked;
  94. }
  95. }
  96. /**
  97. * @internal
  98. */
  99. export class SearchData {
  100. constructor(regex, wordSeparators, simpleSearch) {
  101. this.regex = regex;
  102. this.wordSeparators = wordSeparators;
  103. this.simpleSearch = simpleSearch;
  104. }
  105. }
  106. /**
  107. * @internal
  108. */
  109. export class ApplyEditsResult {
  110. constructor(reverseEdits, changes, trimAutoWhitespaceLineNumbers) {
  111. this.reverseEdits = reverseEdits;
  112. this.changes = changes;
  113. this.trimAutoWhitespaceLineNumbers = trimAutoWhitespaceLineNumbers;
  114. }
  115. }
  116. /**
  117. * @internal
  118. */
  119. export function shouldSynchronizeModel(model) {
  120. return (!model.isTooLargeForSyncing() && !model.isForSimpleWidget);
  121. }