@xterm/addon-search 0.16.0-beta.46 → 0.16.0-beta.47

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.
@@ -14,5 +14,31 @@
14
14
  * Copyright (c) Microsoft Corporation. All rights reserved.
15
15
  * Licensed under the MIT License. See License.txt in the project root for license information.
16
16
  *--------------------------------------------------------------------------------------------*/
17
- var S=class{constructor(){this._listeners=new Set;this._disposed=!1}get event(){return this._event||(this._event=l=>(this._listeners.add(l),{dispose:()=>{this._disposed||this._listeners.delete(l)}})),this._event}fire(l,e){let t=[];for(let s of this._listeners.values())t.push(s);for(let s=0;s<t.length;s++)t[s].call(void 0,l,e)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&this._listeners.clear()}};var C=class{constructor(){this._disposables=[];this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let l of this._disposables)l.dispose();this._disposables.length=0}register(l){return this._disposables.push(l),l}unregister(l){let e=this._disposables.indexOf(l);e!==-1&&this._disposables.splice(e,1)}},m=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(l){this._isDisposed||l===this._value||(this._value?.dispose(),this._value=l)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}};function T(f){return{dispose:f}}function I(f){for(let l of f)l.dispose();f.length=0}function D(f){return{dispose:()=>I(f)}}var L=" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?",A=15*1e3,W=1e3,x=class extends C{constructor(e){super();this._highlightedLines=new Set;this._highlightDecorations=[];this._selectedDecoration=this.register(new m);this._linesCacheTimeoutId=0;this._linesCacheDisposables=new m;this._onDidChangeResults=this.register(new S);this.onDidChangeResults=this._onDidChangeResults.event;this._highlightLimit=e?.highlightLimit??W}activate(e){this._terminal=e,this.register(this._terminal.onWriteParsed(()=>this._updateMatches())),this.register(this._terminal.onResize(()=>this._updateMatches())),this.register(T(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout(()=>{let e=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(e,{...this._lastSearchOptions,incremental:!0,noScroll:!0})},200))}clearDecorations(e){this._selectedDecoration.clear(),I(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),e||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(e,t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let s=this._lastSearchOptions?this._didOptionsChange(this._lastSearchOptions,t):!0;this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||s)&&this._highlightAllMatches(e,t);let i=this._findNextAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,i}_highlightAllMatches(e,t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!e||e.length===0){this.clearDecorations();return}t=t||{},this.clearDecorations(!0);let s=[],i,r=this._find(e,0,0,t);for(;r&&(i?.row!==r.row||i?.col!==r.col)&&!(s.length>=this._highlightLimit);)i=r,s.push(i),r=this._find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);for(let n of s){let o=this._createResultDecoration(n,t.decorations);o&&(this._highlightedLines.add(o.marker.line),this._highlightDecorations.push({decoration:o,match:n,dispose(){o.dispose()}}))}}_find(e,t,s,i){if(!this._terminal||!e||e.length===0){this._terminal?.clearSelection(),this.clearDecorations();return}if(s>this._terminal.cols)throw new Error(`Invalid col: ${s} to search in terminal of ${this._terminal.cols} cols`);let r;this._initLinesCache();let n={startRow:t,startCol:s};if(r=this._findInLine(e,n,i),!r)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(n.startRow=o,n.startCol=0,r=this._findInLine(e,n,i),!r);o++);return r}_findNextAndSelect(e,t){if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,r=0;s&&(this._cachedSearchTerm===e?(i=s.end.x,r=s.end.y):(i=s.start.x,r=s.start.y)),this._initLinesCache();let n={startRow:r,startCol:i},o=this._findInLine(e,n,t);if(!o)for(let a=r+1;a<this._terminal.buffer.active.baseY+this._terminal.rows&&(n.startRow=a,n.startCol=0,o=this._findInLine(e,n,t),!o);a++);if(!o&&r!==0)for(let a=0;a<r&&(n.startRow=a,n.startCol=0,o=this._findInLine(e,n,t),!o);a++);return!o&&s&&(n.startRow=s.start.y,n.startCol=0,o=this._findInLine(e,n,t)),this._selectResult(o,t?.decorations,t?.noScroll)}findPrevious(e,t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let s=this._lastSearchOptions?this._didOptionsChange(this._lastSearchOptions,t):!0;this._lastSearchOptions=t,t?.decorations&&(this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||s)&&this._highlightAllMatches(e,t);let i=this._findPreviousAndSelect(e,t);return this._fireResults(t),this._cachedSearchTerm=e,i}_didOptionsChange(e,t){return t?e.caseSensitive!==t.caseSensitive||e.regex!==t.regex||e.wholeWord!==t.wholeWord:!1}_fireResults(e){if(e?.decorations){let t=-1;if(this._selectedDecoration.value){let s=this._selectedDecoration.value.match;for(let i=0;i<this._highlightDecorations.length;i++){let r=this._highlightDecorations[i].match;if(r.row===s.row&&r.col===s.col&&r.size===s.size){t=i;break}}}this._onDidChangeResults.fire({resultIndex:t,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(e,t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!this._terminal||!e||e.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,r=this._terminal.cols,n=!0;this._initLinesCache();let o={startRow:i,startCol:r},a;if(s&&(o.startRow=i=s.start.y,o.startCol=r=s.start.x,this._cachedSearchTerm!==e&&(a=this._findInLine(e,o,t,!1),a||(o.startRow=i=s.end.y,o.startCol=r=s.end.x))),a||(a=this._findInLine(e,o,t,n)),!a){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let h=i-1;h>=0&&(o.startRow=h,a=this._findInLine(e,o,t,n),!a);h--);}if(!a&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=i&&(o.startRow=h,a=this._findInLine(e,o,t,n),!a);h--);return this._selectResult(a,t?.decorations,t?.noScroll)}_initLinesCache(){let e=this._terminal;this._linesCache||(this._linesCache=new Array(e.buffer.active.length),this._linesCacheDisposables.value=D([e.onLineFeed(()=>this._destroyLinesCache()),e.onCursorMove(()=>this._destroyLinesCache()),e.onResize(()=>this._destroyLinesCache())])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout(()=>this._destroyLinesCache(),A)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)}_isWholeWord(e,t,s){return(e===0||L.includes(t[e-1]))&&(e+s.length===t.length||L.includes(t[e+s.length]))}_findInLine(e,t,s={},i=!1){let r=this._terminal,n=t.startRow,o=t.startCol;if(r.buffer.active.getLine(n)?.isWrapped){if(i){t.startCol+=r.cols;return}return t.startRow--,t.startCol+=r.cols,this._findInLine(e,t,s)}let h=this._linesCache?.[n];h||(h=this._translateBufferLineToStringWithWrap(n,!0),this._linesCache&&(this._linesCache[n]=h));let[g,_]=h,p=this._bufferColsToStringOffset(n,o),v=s.caseSensitive?e:e.toLowerCase(),b=s.caseSensitive?g:g.toLowerCase(),u=-1;if(s.regex){let d=RegExp(v,"g"),c;if(i)for(;c=d.exec(b.slice(0,p));)u=d.lastIndex-c[0].length,e=c[0],d.lastIndex-=e.length-1;else c=d.exec(b.slice(p)),c&&c[0].length>0&&(u=p+(d.lastIndex-c[0].length),e=c[0])}else i?p-v.length>=0&&(u=b.lastIndexOf(v,p-v.length)):u=b.indexOf(v,p);if(u>=0){if(s.wholeWord&&!this._isWholeWord(u,b,e))return;let d=0;for(;d<_.length-1&&u>=_[d+1];)d++;let c=d;for(;c<_.length-1&&u+e.length>=_[c+1];)c++;let R=u-_[d],y=u+e.length-_[c],w=this._stringLengthToBufferSize(n+d,R),E=this._stringLengthToBufferSize(n+c,y)-w+r.cols*(c-d);return{term:e,col:w,row:n+d,size:E}}}_stringLengthToBufferSize(e,t){let s=this._terminal.buffer.active.getLine(e);if(!s)return 0;for(let i=0;i<t;i++){let r=s.getCell(i);if(!r)break;let n=r.getChars();n.length>1&&(t-=n.length-1);let o=s.getCell(i+1);o&&o.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let s=this._terminal,i=e,r=0,n=s.buffer.active.getLine(i);for(;t>0&&n;){for(let o=0;o<t&&o<s.cols;o++){let a=n.getCell(o);if(!a)break;a.getWidth()&&(r+=a.getCode()===0?1:a.getChars().length)}if(i++,n=s.buffer.active.getLine(i),n&&!n.isWrapped)break;t-=s.cols}return r}_translateBufferLineToStringWithWrap(e,t){let s=this._terminal,i=[],r=[0],n=s.buffer.active.getLine(e);for(;n;){let o=s.buffer.active.getLine(e+1),a=o?o.isWrapped:!1,h=n.translateToString(!a&&t);if(a&&o){let g=n.getCell(n.length-1);g&&g.getCode()===0&&g.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(h=h.slice(0,-1))}if(i.push(h),a)r.push(r[r.length-1]+h.length);else break;e++,n=o}return[i.join(""),r]}_selectResult(e,t,s){let i=this._terminal;if(this._selectedDecoration.clear(),!e)return i.clearSelection(),!1;if(i.select(e.col,e.row,e.size),t){let r=i.registerMarker(-i.buffer.active.baseY-i.buffer.active.cursorY+e.row);if(r){let n=i.registerDecoration({marker:r,x:e.col,width:e.size,backgroundColor:t.activeMatchBackground,layer:"top",overviewRulerOptions:{color:t.activeMatchColorOverviewRuler}});if(n){let o=[];o.push(r),o.push(n.onRender(a=>this._applyStyles(a,t.activeMatchBorder,!0))),o.push(n.onDispose(()=>I(o))),this._selectedDecoration.value={decoration:n,match:e,dispose(){n.dispose()}}}}}if(!s&&(e.row>=i.buffer.active.viewportY+i.rows||e.row<i.buffer.active.viewportY)){let r=e.row-i.buffer.active.viewportY;r-=Math.floor(i.rows/2),i.scrollLines(r)}return!0}_applyStyles(e,t,s){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),s&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecoration(e,t){let s=this._terminal,i=s.registerMarker(-s.buffer.active.baseY-s.buffer.active.cursorY+e.row);if(!i)return;let r=s.registerDecoration({marker:i,x:e.col,width:e.size,backgroundColor:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(i.line)?void 0:{color:t.matchOverviewRuler,position:"center"}});if(r){let n=[];n.push(i),n.push(r.onRender(o=>this._applyStyles(o,t.matchBorder,!1))),n.push(r.onDispose(()=>I(n)))}return r}};export{x as SearchAddon};
17
+ var Y=class{constructor(){this._disposables=[];this._isDisposed=!1}dispose(){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.length=0}register(e){return this._disposables.push(e),e}unregister(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1)}},Q=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}};function ye(r){return{dispose:r}}function $(r){for(let e of r)e.dispose();r.length=0}function Ie(r){return{dispose:()=>$(r)}}var le=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?X.isErrorNoTelemetry(e)?new X(e.message+`
18
+
19
+ `+e.stack):new Error(e.message+`
20
+
21
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Qe=new le;function Z(r){$e(r)||Qe.onUnexpectedError(r)}var ue="Canceled";function $e(r){return r instanceof J?!0:r instanceof Error&&r.name===ue&&r.message===ue}var J=class extends Error{constructor(){super(ue),this.name=this.message}};var X=class r extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof r)return e;let t=new r;return t.message=e.message,t.stack=e.stack,t}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}};function de(r,e){let t=this,n=!1,i;return function(){if(n)return i;if(n=!0,e)try{i=r.apply(t,arguments)}finally{e()}else i=r.apply(t,arguments);return i}}function He(r,e,t=0,n=r.length){let i=t,s=n;for(;i<s;){let u=Math.floor((i+s)/2);e(r[u])?i=u+1:s=u}return i-1}var ee=class ee{constructor(e){this._array=e;this._findLastMonotonousLastIdx=0}findLastMonotonous(e){if(ee.assertInvariants){if(this._prevFindLastPredicate){for(let n of this._array)if(this._prevFindLastPredicate(n)&&!e(n))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=e}let t=He(this._array,e,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=t+1,t===-1?void 0:this._array[t]}};ee.assertInvariants=!1;var De=ee;var we;(l=>{function r(o){return o<0}l.isLessThan=r;function e(o){return o<=0}l.isLessThanOrEqual=e;function t(o){return o>0}l.isGreaterThan=t;function n(o){return o===0}l.isNeitherLessOrGreaterThan=n,l.greaterThan=1,l.lessThan=-1,l.neitherLessOrGreaterThan=0})(we||={});function Se(r,e){return(t,n)=>e(r(t),r(n))}var Le=(r,e)=>r-e;var F=class F{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(e){return new F(t=>this.iterate(n=>e(n)?t(n):!0))}map(e){return new F(t=>this.iterate(n=>t(e(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(i=>((n||we.isGreaterThan(e(i,t)))&&(n=!1,t=i),!0)),t}};F.empty=new F(e=>{});var Ee=F;function Ae(r,e){let t=Object.create(null);for(let n of r){let i=e(n),s=t[i];s||(s=t[i]=[]),s.push(n)}return t}var Ce,Re,ke=class{constructor(e,t){this.toKey=t;this._map=new Map;this[Ce]="SetWithKey";for(let n of e)this.add(n)}get size(){return this._map.size}add(e){let t=this.toKey(e);return this._map.set(t,e),this}delete(e){return this._map.delete(this.toKey(e))}has(e){return this._map.has(this.toKey(e))}*entries(){for(let e of this._map.values())yield[e,e]}keys(){return this.values()}*values(){for(let e of this._map.values())yield e}clear(){this._map.clear()}forEach(e,t){this._map.forEach(n=>e.call(t,n,n,this))}[(Re=Symbol.iterator,Ce=Symbol.toStringTag,Re)](){return this.values()}};var te=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){let t=this.map.get(e);return t||new Set}};var ce;(V=>{function r(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}V.is=r;let e=Object.freeze([]);function t(){return e}V.empty=t;function*n(T){yield T}V.single=n;function i(T){return r(T)?T:n(T)}V.wrap=i;function s(T){return T||e}V.from=s;function*u(T){for(let g=T.length-1;g>=0;g--)yield T[g]}V.reverse=u;function l(T){return!T||T[Symbol.iterator]().next().done===!0}V.isEmpty=l;function o(T){return T[Symbol.iterator]().next().value}V.first=o;function f(T,g){let x=0;for(let L of T)if(g(L,x++))return!0;return!1}V.some=f;function m(T,g){for(let x of T)if(g(x))return x}V.find=m;function*b(T,g){for(let x of T)g(x)&&(yield x)}V.filter=b;function*w(T,g){let x=0;for(let L of T)yield g(L,x++)}V.map=w;function*k(T,g){let x=0;for(let L of T)yield*g(L,x++)}V.flatMap=k;function*A(...T){for(let g of T)yield*g}V.concat=A;function R(T,g,x){let L=x;for(let j of T)L=g(L,j);return L}V.reduce=R;function*I(T,g,x=T.length){for(g<0&&(g+=T.length),x<0?x+=T.length:x>T.length&&(x=T.length);g<x;g++)yield T[g]}V.slice=I;function D(T,g=Number.POSITIVE_INFINITY){let x=[];if(g===0)return[x,T];let L=T[Symbol.iterator]();for(let j=0;j<g;j++){let ae=L.next();if(ae.done)return[x,V.empty()];x.push(ae.value)}return[x,{[Symbol.iterator](){return L}}]}V.consume=D;async function y(T){let g=[];for await(let x of T)g.push(x);return Promise.resolve(g)}V.asyncToArray=y})(ce||={});var qe=!1,P=null,ne=class ne{constructor(){this.livingDisposables=new Map}getDisposableData(e){let t=this.livingDisposables.get(e);return t||(t={parent:null,source:null,isSingleton:!1,value:e,idx:ne.idx++},this.livingDisposables.set(e,t)),t}trackDisposable(e){let t=this.getDisposableData(e);t.source||(t.source=new Error().stack)}setParent(e,t){let n=this.getDisposableData(e);n.parent=t}markAsDisposed(e){this.livingDisposables.delete(e)}markAsSingleton(e){this.getDisposableData(e).isSingleton=!0}getRootParent(e,t){let n=t.get(e);if(n)return n;let i=e.parent?this.getRootParent(this.getDisposableData(e.parent),t):e;return t.set(e,i),i}getTrackedDisposables(){let e=new Map;return[...this.livingDisposables.entries()].filter(([,n])=>n.source!==null&&!this.getRootParent(n,e).isSingleton).flatMap(([n])=>n)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let o=new Map,f=[...this.livingDisposables.values()].filter(b=>b.source!==null&&!this.getRootParent(b,o).isSingleton);if(f.length===0)return;let m=new Set(f.map(b=>b.value));if(n=f.filter(b=>!(b.parent&&m.has(b.parent))),n.length===0)throw new Error("There are cyclic diposable chains!")}if(!n)return;function i(o){function f(b,w){for(;b.length>0&&w.some(k=>typeof k=="string"?k===b[0]:b[0].match(k));)b.shift()}let m=o.source.split(`
22
+ `).map(b=>b.trim().replace("at ","")).filter(b=>b!=="");return f(m,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),m.reverse()}let s=new te;for(let o of n){let f=i(o);for(let m=0;m<=f.length;m++)s.add(f.slice(0,m).join(`
23
+ `),o)}n.sort(Se(o=>o.idx,Le));let u="",l=0;for(let o of n.slice(0,e)){l++;let f=i(o),m=[];for(let b=0;b<f.length;b++){let w=f[b];w=`(shared with ${s.get(f.slice(0,b+1).join(`
24
+ `)).size}/${n.length} leaks) at ${w}`;let A=s.get(f.slice(0,b).join(`
25
+ `)),R=Ae([...A].map(I=>i(I)[b]),I=>I);delete R[f[b]];for(let[I,D]of Object.entries(R))m.unshift(` - stacktraces of ${D.length} other leaks continue with ${I}`);m.unshift(w)}u+=`
26
+
27
+
28
+ ==================== Leaking disposable ${l}/${n.length}: ${o.value.constructor.name} ====================
29
+ ${m.join(`
30
+ `)}
31
+ ============================================================
32
+
33
+ `}return n.length>e&&(u+=`
34
+
35
+
36
+ ... and ${n.length-e} more leaking disposables
37
+
38
+ `),{leaks:n,details:u}}};ne.idx=0;var Oe=ne;function Be(r){P=r}if(qe){let r="__is_disposable_tracked__";Be(new class{trackDisposable(e){let t=new Error("Potentially leaked disposable").stack;setTimeout(()=>{e[r]||console.log(t)},3e3)}setParent(e,t){if(e&&e!==O.None)try{e[r]=!0}catch{}}markAsDisposed(e){if(e&&e!==O.None)try{e[r]=!0}catch{}}markAsSingleton(e){}})}function fe(r){return P?.trackDisposable(r),r}function pe(r){P?.markAsDisposed(r)}function he(r,e){P?.setParent(r,e)}function Ge(r,e){if(P)for(let t of r)P.setParent(t,e)}function Me(r){if(ce.is(r)){let e=[];for(let t of r)if(t)try{t.dispose()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(r)?[]:r}else if(r)return r.dispose(),r}function Fe(...r){let e=Te(()=>Me(r));return Ge(r,e),e}function Te(r){let e=fe({dispose:de(()=>{pe(e),r()})});return e}var ie=class ie{constructor(){this._toDispose=new Set;this._isDisposed=!1;fe(this)}dispose(){this._isDisposed||(pe(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Me(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return he(e,this),this._isDisposed?ie.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),he(e,null))}};ie.DISABLE_DISPOSED_WARNING=!1;var N=ie,O=class{constructor(){this._store=new N;fe(this),he(this._store,this)}dispose(){pe(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};O.None=Object.freeze({dispose(){}});var U=class U{constructor(e){this.element=e,this.next=U.Undefined,this.prev=U.Undefined}};U.Undefined=new U(void 0);var Pe=U;var Ye=globalThis.performance&&typeof globalThis.performance.now=="function",se=class r{static create(e){return new r(e)}constructor(e){this._now=Ye&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}};var Je=!1,Ne=!1,Xe=!1,Ze;(q=>{q.None=()=>O.None;function e(h){if(Xe){let{onDidAddListener:a}=h,c=H.create(),d=0;h.onDidAddListener=()=>{++d===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),c.print()),a?.()}}}function t(h,a){return w(h,()=>{},0,void 0,!0,void 0,a)}q.defer=t;function n(h){return(a,c=null,d)=>{let p=!1,v;return v=h(_=>{if(!p)return v?v.dispose():p=!0,a.call(c,_)},null,d),p&&v.dispose(),v}}q.once=n;function i(h,a,c){return m((d,p=null,v)=>h(_=>d.call(p,a(_)),null,v),c)}q.map=i;function s(h,a,c){return m((d,p=null,v)=>h(_=>{a(_),d.call(p,_)},null,v),c)}q.forEach=s;function u(h,a,c){return m((d,p=null,v)=>h(_=>a(_)&&d.call(p,_),null,v),c)}q.filter=u;function l(h){return h}q.signal=l;function o(...h){return(a,c=null,d)=>{let p=Fe(...h.map(v=>v(_=>a.call(c,_))));return b(p,d)}}q.any=o;function f(h,a,c,d){let p=c;return i(h,v=>(p=a(p,v),p),d)}q.reduce=f;function m(h,a){let c,d={onWillAddFirstListener(){c=h(p.fire,p)},onDidRemoveLastListener(){c?.dispose()}};a||e(d);let p=new C(d);return a?.add(p),p.event}function b(h,a){return a instanceof Array?a.push(h):a&&a.add(h),h}function w(h,a,c=100,d=!1,p=!1,v,_){let E,S,M,B=0,K,xe={leakWarningThreshold:v,onWillAddFirstListener(){E=h(je=>{B++,S=a(S,je),d&&!M&&(G.fire(S),S=void 0),K=()=>{let Ke=S;S=void 0,M=void 0,(!d||B>1)&&G.fire(Ke),B=0},typeof c=="number"?(clearTimeout(M),M=setTimeout(K,c)):M===void 0&&(M=0,queueMicrotask(K))})},onWillRemoveListener(){p&&B>0&&K?.()},onDidRemoveLastListener(){K=void 0,E.dispose()}};_||e(xe);let G=new C(xe);return _?.add(G),G.event}q.debounce=w;function k(h,a=0,c){return q.debounce(h,(d,p)=>d?(d.push(p),d):[p],a,void 0,!0,void 0,c)}q.accumulate=k;function A(h,a=(d,p)=>d===p,c){let d=!0,p;return u(h,v=>{let _=d||!a(v,p);return d=!1,p=v,_},c)}q.latch=A;function R(h,a,c){return[q.filter(h,a,c),q.filter(h,d=>!a(d),c)]}q.split=R;function I(h,a=!1,c=[],d){let p=c.slice(),v=h(S=>{p?p.push(S):E.fire(S)});d&&d.add(v);let _=()=>{p?.forEach(S=>E.fire(S)),p=null},E=new C({onWillAddFirstListener(){v||(v=h(S=>E.fire(S)),d&&d.add(v))},onDidAddFirstListener(){p&&(a?setTimeout(_):_())},onDidRemoveLastListener(){v&&v.dispose(),v=null}});return d&&d.add(E),E.event}q.buffer=I;function D(h,a){return(d,p,v)=>{let _=a(new V);return h(function(E){let S=_.evaluate(E);S!==y&&d.call(p,S)},void 0,v)}}q.chain=D;let y=Symbol("HaltChainable");class V{constructor(){this.steps=[]}map(a){return this.steps.push(a),this}forEach(a){return this.steps.push(c=>(a(c),c)),this}filter(a){return this.steps.push(c=>a(c)?c:y),this}reduce(a,c){let d=c;return this.steps.push(p=>(d=a(d,p),d)),this}latch(a=(c,d)=>c===d){let c=!0,d;return this.steps.push(p=>{let v=c||!a(p,d);return c=!1,d=p,v?p:y}),this}evaluate(a){for(let c of this.steps)if(a=c(a),a===y)break;return a}}function T(h,a,c=d=>d){let d=(...E)=>_.fire(c(...E)),p=()=>h.on(a,d),v=()=>h.removeListener(a,d),_=new C({onWillAddFirstListener:p,onDidRemoveLastListener:v});return _.event}q.fromNodeEventEmitter=T;function g(h,a,c=d=>d){let d=(...E)=>_.fire(c(...E)),p=()=>h.addEventListener(a,d),v=()=>h.removeEventListener(a,d),_=new C({onWillAddFirstListener:p,onDidRemoveLastListener:v});return _.event}q.fromDOMEventEmitter=g;function x(h){return new Promise(a=>n(h)(a))}q.toPromise=x;function L(h){let a=new C;return h.then(c=>{a.fire(c)},()=>{a.fire(void 0)}).finally(()=>{a.dispose()}),a.event}q.fromPromise=L;function j(h,a){return h(c=>a.fire(c))}q.forward=j;function ae(h,a,c){return a(c),h(d=>a(d))}q.runAndSubscribe=ae;class Ve{constructor(a,c){this._observable=a;this._counter=0;this._hasChanged=!1;let d={onWillAddFirstListener:()=>{a.addObserver(this)},onDidRemoveLastListener:()=>{a.removeObserver(this)}};c||e(d),this.emitter=new C(d),c&&c.add(this.emitter)}beginUpdate(a){this._counter++}handlePossibleChange(a){}handleChange(a,c){this._hasChanged=!0}endUpdate(a){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function rt(h,a){return new Ve(h,a).emitter.event}q.fromObservable=rt;function ot(h){return(a,c,d)=>{let p=0,v=!1,_={beginUpdate(){p++},endUpdate(){p--,p===0&&(h.reportChanges(),v&&(v=!1,a.call(c)))},handlePossibleChange(){},handleChange(){v=!0}};h.addObserver(_),h.reportChanges();let E={dispose(){h.removeObserver(_)}};return d instanceof N?d.add(E):Array.isArray(d)&&d.push(E),E}}q.fromObservableLight=ot})(Ze||={});var W=class W{constructor(e){this.listenerCount=0;this.invocationCount=0;this.elapsedOverall=0;this.durations=[];this.name=`${e}_${W._idPool++}`,W.all.add(this)}start(e){this._stopWatch=new se,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};W.all=new Set,W._idPool=0;var ve=W,Ue=-1;var oe=class oe{constructor(e,t,n=(oe._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e;this.threshold=t;this.name=n;this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[s,u]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${u}):`;console.warn(l),console.warn(s);let o=new be(l,s);this._errorHandler(o)}return()=>{let s=this._stacks.get(e.value)||0;this._stacks.set(e.value,s-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,i]of this._stacks)(!e||t<i)&&(e=[n,i],t=i);return e}};oe._idPool=1;var me=oe,H=class r{constructor(e){this.value=e}static create(){let e=new Error;return new r(e.stack??"")}print(){console.warn(this.value.split(`
39
+ `).slice(2).join(`
40
+ `))}},be=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ge=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},et=0,z=class{constructor(e){this.value=e;this.id=et++}},tt=2,nt=(r,e)=>{if(r instanceof z)e(r);else for(let t=0;t<r.length;t++){let n=r[t];n&&e(n)}},re;if(Je){let r=[];setInterval(()=>{r.length!==0&&(console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"),console.warn(r.join(`
41
+ `)),r.length=0)},3e3),re=new FinalizationRegistry(e=>{typeof e=="string"&&r.push(e)})}var C=class{constructor(e){this._size=0;this._options=e,this._leakageMon=Ue>0||this._options?.leakWarningThreshold?new me(e?.onListenerError??Z,this._options?.leakWarningThreshold??Ue):void 0,this._perfMon=this._options?._profName?new ve(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Ne){let e=this._listeners;queueMicrotask(()=>{nt(e,t=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],m=new ge(`${o}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||Z)(m),O.None}if(this._disposed)return O.None;t&&(e=e.bind(t));let i=new z(e),s,u;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=H.create(),s=this._leakageMon.check(i.stack,this._size+1)),Ne&&(i.stack=u??H.create()),this._listeners?this._listeners instanceof z?(this._deliveryQueue??=new _e,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let l=Te(()=>{re?.unregister(l),s?.(),this._removeListener(i)});if(n instanceof N?n.add(l):Array.isArray(n)&&n.push(l),re){let o=new Error().stack.split(`
42
+ `).slice(2,3).join(`
43
+ `).trim(),f=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(o);re.register(l,f?.[2]??o,l)}return l},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let i=this._deliveryQueue.current===this;if(this._size*tt<=t.length){let s=0;for(let u=0;u<t.length;u++)t[u]?t[s++]=t[u]:i&&(this._deliveryQueue.end--,s<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=s}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||Z;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof z)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}};var _e=class{constructor(){this.i=-1;this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}};var We=" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?",it=15*1e3,st=1e3,ze=class extends Y{constructor(t){super();this._highlightedLines=new Set;this._highlightDecorations=[];this._selectedDecoration=this.register(new Q);this._linesCacheTimeoutId=0;this._linesCacheDisposables=new Q;this._onDidChangeResults=this.register(new C);this.onDidChangeResults=this._onDidChangeResults.event;this._highlightLimit=t?.highlightLimit??st}activate(t){this._terminal=t,this.register(this._terminal.onWriteParsed(()=>this._updateMatches())),this.register(this._terminal.onResize(()=>this._updateMatches())),this.register(ye(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout(()=>{let t=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(t,{...this._lastSearchOptions,incremental:!0,noScroll:!0})},200))}clearDecorations(t){this._selectedDecoration.clear(),$(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),t||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(t,n){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let i=this._lastSearchOptions?this._didOptionsChange(this._lastSearchOptions,n):!0;this._lastSearchOptions=n,n?.decorations&&(this._cachedSearchTerm===void 0||t!==this._cachedSearchTerm||i)&&this._highlightAllMatches(t,n);let s=this._findNextAndSelect(t,n);return this._fireResults(n),this._cachedSearchTerm=t,s}_highlightAllMatches(t,n){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!t||t.length===0){this.clearDecorations();return}n=n||{},this.clearDecorations(!0);let i=[],s,u=this._find(t,0,0,n);for(;u&&(s?.row!==u.row||s?.col!==u.col)&&!(i.length>=this._highlightLimit);)s=u,i.push(s),u=this._find(t,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,n);for(let l of i){let o=this._createResultDecoration(l,n.decorations);o&&(this._highlightedLines.add(o.marker.line),this._highlightDecorations.push({decoration:o,match:l,dispose(){o.dispose()}}))}}_find(t,n,i,s){if(!this._terminal||!t||t.length===0){this._terminal?.clearSelection(),this.clearDecorations();return}if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);let u;this._initLinesCache();let l={startRow:n,startCol:i};if(u=this._findInLine(t,l,s),!u)for(let o=n+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(l.startRow=o,l.startCol=0,u=this._findInLine(t,l,s),!u);o++);return u}_findNextAndSelect(t,n){if(!this._terminal||!t||t.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=0,u=0;i&&(this._cachedSearchTerm===t?(s=i.end.x,u=i.end.y):(s=i.start.x,u=i.start.y)),this._initLinesCache();let l={startRow:u,startCol:s},o=this._findInLine(t,l,n);if(!o)for(let f=u+1;f<this._terminal.buffer.active.baseY+this._terminal.rows&&(l.startRow=f,l.startCol=0,o=this._findInLine(t,l,n),!o);f++);if(!o&&u!==0)for(let f=0;f<u&&(l.startRow=f,l.startCol=0,o=this._findInLine(t,l,n),!o);f++);return!o&&i&&(l.startRow=i.start.y,l.startCol=0,o=this._findInLine(t,l,n)),this._selectResult(o,n?.decorations,n?.noScroll)}findPrevious(t,n){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let i=this._lastSearchOptions?this._didOptionsChange(this._lastSearchOptions,n):!0;this._lastSearchOptions=n,n?.decorations&&(this._cachedSearchTerm===void 0||t!==this._cachedSearchTerm||i)&&this._highlightAllMatches(t,n);let s=this._findPreviousAndSelect(t,n);return this._fireResults(n),this._cachedSearchTerm=t,s}_didOptionsChange(t,n){return n?t.caseSensitive!==n.caseSensitive||t.regex!==n.regex||t.wholeWord!==n.wholeWord:!1}_fireResults(t){if(t?.decorations){let n=-1;if(this._selectedDecoration.value){let i=this._selectedDecoration.value.match;for(let s=0;s<this._highlightDecorations.length;s++){let u=this._highlightDecorations[s].match;if(u.row===i.row&&u.col===i.col&&u.size===i.size){n=s;break}}}this._onDidChangeResults.fire({resultIndex:n,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(t,n){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!this._terminal||!t||t.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;let i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=this._terminal.buffer.active.baseY+this._terminal.rows-1,u=this._terminal.cols,l=!0;this._initLinesCache();let o={startRow:s,startCol:u},f;if(i&&(o.startRow=s=i.start.y,o.startCol=u=i.start.x,this._cachedSearchTerm!==t&&(f=this._findInLine(t,o,n,!1),f||(o.startRow=s=i.end.y,o.startCol=u=i.end.x))),f||(f=this._findInLine(t,o,n,l)),!f){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let m=s-1;m>=0&&(o.startRow=m,f=this._findInLine(t,o,n,l),!f);m--);}if(!f&&s!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let m=this._terminal.buffer.active.baseY+this._terminal.rows-1;m>=s&&(o.startRow=m,f=this._findInLine(t,o,n,l),!f);m--);return this._selectResult(f,n?.decorations,n?.noScroll)}_initLinesCache(){let t=this._terminal;this._linesCache||(this._linesCache=new Array(t.buffer.active.length),this._linesCacheDisposables.value=Ie([t.onLineFeed(()=>this._destroyLinesCache()),t.onCursorMove(()=>this._destroyLinesCache()),t.onResize(()=>this._destroyLinesCache())])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout(()=>this._destroyLinesCache(),it)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)}_isWholeWord(t,n,i){return(t===0||We.includes(n[t-1]))&&(t+i.length===n.length||We.includes(n[t+i.length]))}_findInLine(t,n,i={},s=!1){let u=this._terminal,l=n.startRow,o=n.startCol;if(u.buffer.active.getLine(l)?.isWrapped){if(s){n.startCol+=u.cols;return}return n.startRow--,n.startCol+=u.cols,this._findInLine(t,n,i)}let m=this._linesCache?.[l];m||(m=this._translateBufferLineToStringWithWrap(l,!0),this._linesCache&&(this._linesCache[l]=m));let[b,w]=m,k=this._bufferColsToStringOffset(l,o),A=i.caseSensitive?t:t.toLowerCase(),R=i.caseSensitive?b:b.toLowerCase(),I=-1;if(i.regex){let D=RegExp(A,"g"),y;if(s)for(;y=D.exec(R.slice(0,k));)I=D.lastIndex-y[0].length,t=y[0],D.lastIndex-=t.length-1;else y=D.exec(R.slice(k)),y&&y[0].length>0&&(I=k+(D.lastIndex-y[0].length),t=y[0])}else s?k-A.length>=0&&(I=R.lastIndexOf(A,k-A.length)):I=R.indexOf(A,k);if(I>=0){if(i.wholeWord&&!this._isWholeWord(I,R,t))return;let D=0;for(;D<w.length-1&&I>=w[D+1];)D++;let y=D;for(;y<w.length-1&&I+t.length>=w[y+1];)y++;let V=I-w[D],T=I+t.length-w[y],g=this._stringLengthToBufferSize(l+D,V),L=this._stringLengthToBufferSize(l+y,T)-g+u.cols*(y-D);return{term:t,col:g,row:l+D,size:L}}}_stringLengthToBufferSize(t,n){let i=this._terminal.buffer.active.getLine(t);if(!i)return 0;for(let s=0;s<n;s++){let u=i.getCell(s);if(!u)break;let l=u.getChars();l.length>1&&(n-=l.length-1);let o=i.getCell(s+1);o&&o.getWidth()===0&&n++}return n}_bufferColsToStringOffset(t,n){let i=this._terminal,s=t,u=0,l=i.buffer.active.getLine(s);for(;n>0&&l;){for(let o=0;o<n&&o<i.cols;o++){let f=l.getCell(o);if(!f)break;f.getWidth()&&(u+=f.getCode()===0?1:f.getChars().length)}if(s++,l=i.buffer.active.getLine(s),l&&!l.isWrapped)break;n-=i.cols}return u}_translateBufferLineToStringWithWrap(t,n){let i=this._terminal,s=[],u=[0],l=i.buffer.active.getLine(t);for(;l;){let o=i.buffer.active.getLine(t+1),f=o?o.isWrapped:!1,m=l.translateToString(!f&&n);if(f&&o){let b=l.getCell(l.length-1);b&&b.getCode()===0&&b.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(m=m.slice(0,-1))}if(s.push(m),f)u.push(u[u.length-1]+m.length);else break;t++,l=o}return[s.join(""),u]}_selectResult(t,n,i){let s=this._terminal;if(this._selectedDecoration.clear(),!t)return s.clearSelection(),!1;if(s.select(t.col,t.row,t.size),n){let u=s.registerMarker(-s.buffer.active.baseY-s.buffer.active.cursorY+t.row);if(u){let l=s.registerDecoration({marker:u,x:t.col,width:t.size,backgroundColor:n.activeMatchBackground,layer:"top",overviewRulerOptions:{color:n.activeMatchColorOverviewRuler}});if(l){let o=[];o.push(u),o.push(l.onRender(f=>this._applyStyles(f,n.activeMatchBorder,!0))),o.push(l.onDispose(()=>$(o))),this._selectedDecoration.value={decoration:l,match:t,dispose(){l.dispose()}}}}}if(!i&&(t.row>=s.buffer.active.viewportY+s.rows||t.row<s.buffer.active.viewportY)){let u=t.row-s.buffer.active.viewportY;u-=Math.floor(s.rows/2),s.scrollLines(u)}return!0}_applyStyles(t,n,i){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),n&&(t.style.outline=`1px solid ${n}`)),i&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecoration(t,n){let i=this._terminal,s=i.registerMarker(-i.buffer.active.baseY-i.buffer.active.cursorY+t.row);if(!s)return;let u=i.registerDecoration({marker:s,x:t.col,width:t.size,backgroundColor:n.matchBackground,overviewRulerOptions:this._highlightedLines.has(s.line)?void 0:{color:n.matchOverviewRuler,position:"center"}});if(u){let l=[];l.push(s),l.push(u.onRender(o=>this._applyStyles(o,n.matchBorder,!1))),l.push(u.onDispose(()=>$(l)))}return u}};export{ze as SearchAddon};
18
44
  //# sourceMappingURL=xterm-addon-search.mjs.map