@xterm/addon-search 0.16.0-beta.120 → 0.16.0-beta.122

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xterm/addon-search",
3
- "version": "0.16.0-beta.120",
3
+ "version": "0.16.0-beta.122",
4
4
  "author": {
5
5
  "name": "The xterm.js authors",
6
6
  "url": "https://xtermjs.org/"
@@ -22,7 +22,7 @@
22
22
  "start": "node ../../demo/start"
23
23
  },
24
24
  "peerDependencies": {
25
- "@xterm/xterm": "^5.6.0-beta.120"
25
+ "@xterm/xterm": "^5.6.0-beta.122"
26
26
  },
27
- "commit": "ab01a5fd659671ccd5c8c45faa0afe354f09c759"
27
+ "commit": "e37aba592464668145f61ee874ab9d4a95fc56a9"
28
28
  }
@@ -68,11 +68,32 @@ interface IMultiHighlight extends IDisposable {
68
68
  match: ISearchResult;
69
69
  }
70
70
 
71
- const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\\;:"\',./<>?';
72
- const LINES_CACHE_TIME_TO_LIVE = 15 * 1000; // 15 secs
73
- const DEFAULT_HIGHLIGHT_LIMIT = 1000;
71
+ /**
72
+ * Configuration constants for the search addon functionality.
73
+ */
74
+ const enum Constants {
75
+ /**
76
+ * Characters that are considered non-word characters for search boundary detection. These
77
+ * characters are used to determine word boundaries when performing whole-word searches. Includes
78
+ * common punctuation, symbols, and whitespace characters.
79
+ */
80
+ NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\\;:"\',./<>?',
81
+
82
+ /**
83
+ * Time-to-live for cached search results in milliseconds. After this duration, cached search
84
+ * results will be invalidated to ensure they remain consistent with terminal content changes.
85
+ */
86
+ LINES_CACHE_TIME_TO_LIVE = 15000,
87
+
88
+ /**
89
+ * Default maximum number of search results to highlight simultaneously. This limit prevents
90
+ * performance degradation when searching for very common terms that would result in excessive
91
+ * highlighting decorations.
92
+ */
93
+ DEFAULT_HIGHLIGHT_LIMIT = 1000
94
+ }
74
95
 
75
- export class SearchAddon extends Disposable implements ITerminalAddon , ISearchApi {
96
+ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchApi {
76
97
  private _terminal: Terminal | undefined;
77
98
  private _cachedSearchTerm: string | undefined;
78
99
  private _highlightedLines: Set<number> = new Set();
@@ -97,7 +118,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
97
118
  constructor(options?: Partial<ISearchAddonOptions>) {
98
119
  super();
99
120
 
100
- this._highlightLimit = options?.highlightLimit ?? DEFAULT_HIGHLIGHT_LIMIT;
121
+ this._highlightLimit = options?.highlightLimit ?? Constants.DEFAULT_HIGHLIGHT_LIMIT;
101
122
  }
102
123
 
103
124
  public activate(terminal: Terminal): void {
@@ -451,7 +472,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
451
472
  }
452
473
 
453
474
  window.clearTimeout(this._linesCacheTimeoutId);
454
- this._linesCacheTimeoutId = window.setTimeout(() => this._destroyLinesCache(), LINES_CACHE_TIME_TO_LIVE);
475
+ this._linesCacheTimeoutId = window.setTimeout(() => this._destroyLinesCache(), Constants.LINES_CACHE_TIME_TO_LIVE);
455
476
  }
456
477
 
457
478
  private _destroyLinesCache(): void {
@@ -471,8 +492,8 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
471
492
  * @param term the substring that starts at searchIndex
472
493
  */
473
494
  private _isWholeWord(searchIndex: number, line: string, term: string): boolean {
474
- return ((searchIndex === 0) || (NON_WORD_CHARACTERS.includes(line[searchIndex - 1]))) &&
475
- (((searchIndex + term.length) === line.length) || (NON_WORD_CHARACTERS.includes(line[searchIndex + term.length])));
495
+ return ((searchIndex === 0) || (Constants.NON_WORD_CHARACTERS.includes(line[searchIndex - 1]))) &&
496
+ (((searchIndex + term.length) === line.length) || (Constants.NON_WORD_CHARACTERS.includes(line[searchIndex + term.length])));
476
497
  }
477
498
 
478
499
  /**