model.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. * Vertical Lane in the glyph margin of the editor.
  18. */
  19. export var GlyphMarginLane;
  20. (function (GlyphMarginLane) {
  21. GlyphMarginLane[GlyphMarginLane["Left"] = 1] = "Left";
  22. GlyphMarginLane[GlyphMarginLane["Right"] = 2] = "Right";
  23. })(GlyphMarginLane || (GlyphMarginLane = {}));
  24. /**
  25. * Position in the minimap to render the decoration.
  26. */
  27. export var MinimapPosition;
  28. (function (MinimapPosition) {
  29. MinimapPosition[MinimapPosition["Inline"] = 1] = "Inline";
  30. MinimapPosition[MinimapPosition["Gutter"] = 2] = "Gutter";
  31. })(MinimapPosition || (MinimapPosition = {}));
  32. export var InjectedTextCursorStops;
  33. (function (InjectedTextCursorStops) {
  34. InjectedTextCursorStops[InjectedTextCursorStops["Both"] = 0] = "Both";
  35. InjectedTextCursorStops[InjectedTextCursorStops["Right"] = 1] = "Right";
  36. InjectedTextCursorStops[InjectedTextCursorStops["Left"] = 2] = "Left";
  37. InjectedTextCursorStops[InjectedTextCursorStops["None"] = 3] = "None";
  38. })(InjectedTextCursorStops || (InjectedTextCursorStops = {}));
  39. export class TextModelResolvedOptions {
  40. get originalIndentSize() {
  41. return this._indentSizeIsTabSize ? 'tabSize' : this.indentSize;
  42. }
  43. /**
  44. * @internal
  45. */
  46. constructor(src) {
  47. this._textModelResolvedOptionsBrand = undefined;
  48. this.tabSize = Math.max(1, src.tabSize | 0);
  49. if (src.indentSize === 'tabSize') {
  50. this.indentSize = this.tabSize;
  51. this._indentSizeIsTabSize = true;
  52. }
  53. else {
  54. this.indentSize = Math.max(1, src.indentSize | 0);
  55. this._indentSizeIsTabSize = false;
  56. }
  57. this.insertSpaces = Boolean(src.insertSpaces);
  58. this.defaultEOL = src.defaultEOL | 0;
  59. this.trimAutoWhitespace = Boolean(src.trimAutoWhitespace);
  60. this.bracketPairColorizationOptions = src.bracketPairColorizationOptions;
  61. }
  62. /**
  63. * @internal
  64. */
  65. equals(other) {
  66. return (this.tabSize === other.tabSize
  67. && this._indentSizeIsTabSize === other._indentSizeIsTabSize
  68. && this.indentSize === other.indentSize
  69. && this.insertSpaces === other.insertSpaces
  70. && this.defaultEOL === other.defaultEOL
  71. && this.trimAutoWhitespace === other.trimAutoWhitespace
  72. && equals(this.bracketPairColorizationOptions, other.bracketPairColorizationOptions));
  73. }
  74. /**
  75. * @internal
  76. */
  77. createChangeEvent(newOpts) {
  78. return {
  79. tabSize: this.tabSize !== newOpts.tabSize,
  80. indentSize: this.indentSize !== newOpts.indentSize,
  81. insertSpaces: this.insertSpaces !== newOpts.insertSpaces,
  82. trimAutoWhitespace: this.trimAutoWhitespace !== newOpts.trimAutoWhitespace,
  83. };
  84. }
  85. }
  86. export class FindMatch {
  87. /**
  88. * @internal
  89. */
  90. constructor(range, matches) {
  91. this._findMatchBrand = undefined;
  92. this.range = range;
  93. this.matches = matches;
  94. }
  95. }
  96. /**
  97. * @internal
  98. */
  99. export function isITextSnapshot(obj) {
  100. return (obj && typeof obj.read === 'function');
  101. }
  102. /**
  103. * @internal
  104. */
  105. export class ValidAnnotatedEditOperation {
  106. constructor(identifier, range, text, forceMoveMarkers, isAutoWhitespaceEdit, _isTracked) {
  107. this.identifier = identifier;
  108. this.range = range;
  109. this.text = text;
  110. this.forceMoveMarkers = forceMoveMarkers;
  111. this.isAutoWhitespaceEdit = isAutoWhitespaceEdit;
  112. this._isTracked = _isTracked;
  113. }
  114. }
  115. /**
  116. * @internal
  117. */
  118. export class SearchData {
  119. constructor(regex, wordSeparators, simpleSearch) {
  120. this.regex = regex;
  121. this.wordSeparators = wordSeparators;
  122. this.simpleSearch = simpleSearch;
  123. }
  124. }
  125. /**
  126. * @internal
  127. */
  128. export class ApplyEditsResult {
  129. constructor(reverseEdits, changes, trimAutoWhitespaceLineNumbers) {
  130. this.reverseEdits = reverseEdits;
  131. this.changes = changes;
  132. this.trimAutoWhitespaceLineNumbers = trimAutoWhitespaceLineNumbers;
  133. }
  134. }
  135. /**
  136. * @internal
  137. */
  138. export function shouldSynchronizeModel(model) {
  139. return (!model.isTooLargeForSyncing() && !model.isForSimpleWidget);
  140. }