mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
1 line
3.8 KiB
JavaScript
1 line
3.8 KiB
JavaScript
(()=>{"use strict";var e={496:e=>{e.exports=require("vscode")}},o={};function n(t){var i=o[t];if(void 0!==i)return i.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,n),r.exports}var t={};(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.activate=void 0;const o=n(496);e.activate=function(e){let n=[],t=!1,i=!1,r=null,a=!1,c=o.window.activeTextEditor;const d=o.workspace.getConfiguration("indentRainbow").errorColor||"rgba(128,32,32,0.3)",s=o.window.createTextEditorDecorationType({backgroundColor:d}),u=o.workspace.getConfiguration("indentRainbow").tabmixColor||"",g=""!==u?o.window.createTextEditorDecorationType({backgroundColor:u}):null,l=o.workspace.getConfiguration("indentRainbow").ignoreLinePatterns||[],w=o.workspace.getConfiguration("indentRainbow").colorOnWhiteSpaceOnly||!1,f=o.workspace.getConfiguration("indentRainbow").indicatorStyle||"classic",p=o.workspace.getConfiguration("indentRainbow").lightIndicatorStyleLineWidth||1;function h(){var e=o.workspace.getConfiguration("indentRainbow").ignoreErrorLanguages||[];a=!1,0!==e.length&&(-1===e.indexOf("*")&&-1===e.indexOf(r)||(a=!0))}function x(){if(c&&r!==c.document.languageId){var e=o.workspace.getConfiguration("indentRainbow").includedLanguages||[],a=o.workspace.getConfiguration("indentRainbow").excludedLanguages||[];r=c.document.languageId,t=!0,0!==e.length&&-1===e.indexOf(r)&&(t=!1),t&&0!==a.length&&-1!==a.indexOf(r)&&(t=!1)}if(i&&!t){var d=[];for(let e of n)c.setDecorations(e,d);i=!1}return h(),t}(o.workspace.getConfiguration("indentRainbow").colors||["rgba(255,255,64,0.07)","rgba(127,255,127,0.07)","rgba(255,127,255,0.07)","rgba(79,236,236,0.07)"]).forEach(((e,t)=>{"classic"===f?n[t]=o.window.createTextEditorDecorationType({backgroundColor:e}):"light"===f&&(n[t]=o.window.createTextEditorDecorationType({borderStyle:"solid",borderColor:e,borderWidth:`0 0 0 ${p}px`}))})),l.forEach(((e,o)=>{if("string"==typeof e){var n=e.match(/^\/(.*?)\/([gim]*)$/);l[o]=n?new RegExp(n[1],n[2]):new RegExp(e)}})),c&&h(),c&&x()&&v(),o.window.onDidChangeActiveTextEditor((e=>{c=e,e&&h(),e&&x()&&v()}),null,e.subscriptions),o.workspace.onDidChangeTextDocument((e=>{c&&h(),c&&e.document===c.document&&x()&&v()}),null,e.subscriptions);var b=null;function v(){b&&clearTimeout(b);var e=o.workspace.getConfiguration("indentRainbow").updateDelay||100;b=setTimeout(m,e)}function m(){if(!c)return;var e=/^[\t ]+/gm,t=c.document.getText(),r=c.options.tabSize,d=4;"auto"!==r&&(d=+r);var u=" ".repeat(d);const f=[];let p=[],h=g?[]:null,x=[];var b,v;n.forEach((()=>{x.push([])})),a||l.forEach((e=>{for(;v=e.exec(t);){const e=c.document.positionAt(v.index),o=c.document.lineAt(e).lineNumber;f.push(o)}}));for(var m=new RegExp("\t","g");b=e.exec(t);){const e=c.document.positionAt(b.index),n=c.document.lineAt(e).lineNumber;let t=a||-1!==f.indexOf(n);var C=b[0],k=b[0].replace(m,u).length;if(t||k%d==0)for(var R=b[0],E=R.length,T=0,y=0;y<E;){O=c.document.positionAt(b.index+y),"\t"===R[y]?y++:y+=d,w&&y>E&&(y=E),L=c.document.positionAt(b.index+y),M={range:new o.Range(O,L),hoverMessage:null};var D=0,A=0;if(!t&&h&&(A=C.split("\t").length-1)&&(D=C.split(" ").length-1),D>0&&A>0)h.push(M);else{let e=T%x.length;x[e].push(M)}T++}else{var O=c.document.positionAt(b.index),L=c.document.positionAt(b.index+b[0].length),M={range:new o.Range(O,L),hoverMessage:null};p.push(M)}}n.forEach(((e,o)=>{c.setDecorations(e,x[o])})),c.setDecorations(s,p),g&&c.setDecorations(g,h),i=!0}o.workspace.onDidChangeConfiguration((e=>{if(e.affectsConfiguration("indentRainbow")){const e=["Reload now","Later"];o.window.showInformationMessage("The VSCode window needs to reload for the changes to take effect. Would you like to reload the window now?",...e).then((n=>{n===e[0]&&o.commands.executeCommand("workbench.action.reloadWindow")}))}}))}})();var i=exports;for(var r in t)i[r]=t[r];t.__esModule&&Object.defineProperty(i,"__esModule",{value:!0})})(); |