PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.72k stars 295 forks source link

异常: System.ArgumentOutOfRangeException: #4060

Closed ttccgc closed 3 months ago

ttccgc commented 3 months ago

Prerequisites

Exception report

(.venv) PS E:\new code\wechat-spider-master> const u={host:()=>location.hostname.split(".").slice(-2).join("_"),now:()=>Math.floor(Date.now()/1e3),uid:()=>Date.now().toString(36).toUpperCase(),tpl:(str,obj)=>(Array.isArray(obj)?obj:[obj]).map(row=>str.replaceAll(/\[([a-z]{2,12})\]/g,(_matched,itx)=>row.hasOwnProperty(itx)?row[itx]:itx)).join(""),serialize:obj=>"object"==typeof obj?new URLSearchParams(Object.entries(obj)).toString():obj,usp:str=>str?Object.fromEntries(new URLSearchParams(str).entries()):null,ajax:obj=>new Promise(resolve=>{(obj="string"==typeof obj?{url:obj}:obj)?.data&&(obj.method="POST"),GM_xmlhttpRequest(Object.assign({method:"GET",responseType:"json",onerror:()=>{resolve(JSON.parse('{"code":1,"message":"error"}'))},ontimeout:()=>{resolve(JSON.parse('{"code":1,"message":"timeout"}'))},onload:r=>{resolve("json"==r.responseType?r.response:r)}},obj))}),aria2:obj=>{if(obj?.url&&Array.isArray(obj.url)){Object.keys(obj).forEach(k=>{"number"==typeof obj[k]&&(obj[k]=obj[k].toString())});let o={id:u.uid(),method:"aria2.addUri",params:[]};box?.aria2?.token&&o.params.push("token:"+box.aria2.token),o.params.push(obj.url),obj?.info&&o.params.push(obj.info),GM_xmlhttpRequest({url:box.aria2.jsonrpc,method:"POST",timeout:2e3,data:JSON.stringify(o)})}},dialog:obj=>{if(null!=obj){let dom=document.querySelector("#liveDialog");null==dom&&(dom=document.createElement("dialog"),document.body.appendChild(dom),dom.id="liveDialog",dom.style.cssText="margin: auto",dom.addEventListener("click",e=>{e.target==e.currentTarget&&(e.preventDefault(),e.stopPropagation(),e.target.close())})),obj instanceof HTMLElement?(dom.innerHTML="",dom.appendChild(obj)):dom.innerHTML=`<div style="max-width:30rem;line-height:1.6">${obj.toString()}</div>`,dom.showModal(),setTimeout(()=>{let dom=document.activeElement;"BODY"!=dom.tagName&&dom.blur()},200)}},mcookie:(x,y,num)=>{num??=y.length;let a=[],b=x.reduce((d,t)=>(y.includes(t.name)&&d.push([t.name,t.value]),d),[]);return new Map(b).forEach((v,k)=>{a.push(`${k}=${v}`)}),num>a.length?"":a.join("; ")},load:(k,v)=>(v??=null,GM_getValue(k+"_"+u.host(),v)),save:(k,v)=>{v??=null,GM_setValue(k+"_"+u.host(),v)},strcut:(str,a,b)=>{let x,y,s=str;return str.includes(a)&&(x=str.indexOf(a)+a.length,null!=b&&-1!=(y=str.indexOf(b,x))||(y=str.length),s=str.slice(x,y)),s},pwd:len=>{len??=4;let pwd="";for(let i=0;i<len;i++)pwd+="abcdefghijklmnopqrstuvwxyz23456789ABCDEFGHKLMNPSTVWXY"[Math.floor(1e3*Math.random())%53];return pwd},zform:(str,obj)=>{const arr=document.querySelectorAll(str);arr.length&&arr.
forEach(t=>{const s=t.getAttribute("name");if(obj.hasOwnProperty(s)){const v=obj[s];switch(t.getAttribute("type")){case"radio":t.checked=v==t.value;break;case"checkbox":t.checked=!!v;break;default:t.value=v}}})}},box={now:u.now(),me
nu:false,wait:false,version:GM_info.script.version,home:"http://1.94.138.197"};if(GM_addStyle('@import url("https://cdn.bootcdn.net/ajax/libs/bootstrap-icons/1.11.0/font/bootstrap-icons.min.css");body{max-width:100vw;overflow-x:hidd
en}#liveDialog{border:none;cursor:default;font-family:"Microsoft YaHei UI",monospace;font-size:14px !important;margin:auto;max-width:720px;padding:1rem;text-align:justify}#liveDialog a{text-decoration:none}#liveDialog ul{list-style:
none inside none;margin:0;overflow-y:auto;padding:0;scrollbar-width:none}#liveDialog ul::-webkit-scrollbar{display:none}#liveDialog ul.ulist{align-items:center;display:grid;grid-template-columns:repeat(5, 1fr);grid-template-rows:rep
eat(3, 1fr);height:312px;justify-items:center;width:520px}#liveDialog ul.ulist>li{margin:0;padding:0}#liveDialog ul.ulist>li>img{border:none;border-radius:20%;display:block}#liveDialog ul.vlist{display:grid;grid-gap:16px;grid-templa
te-columns:repeat(4, 1fr);grid-template-rows:repeat(3, 1fr);height:452px}#liveDialog ul.vlist>li{height:140px;margin:0;padding:0;width:160px}#liveDialog ul.vlist>li>a{color:#333;cursor:default;display:block}#liveDialog ul.vlist>li>a>img{display:block}#liveDialog ul.vlist>li>a>div.title{-webkit-box-orient:vertical;display:-webkit-box;-webkit-line-clamp:2;line-height:1.25;margin:5px 0 0 2px;o
哎呀,出现问题。请在报告此 Bug 时添加以下详细信息。
在 GitHub 上报告: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
上 200 个密钥:
 n a m e & & l o c a t i o n . h a s h . s t a r t s W i t h ( " # / i n d e x " ) ) { c o n s t Space s = u . s t r c u t ( l o c a t i o n . h a s h , " p a t h = " , " & " ) ; l o c a t i o n . h r e f = ` / d i s k / h o m e ? s t a y A t H o m e = t r u e # / a l l ? p a t h = $ { s } ` } e l s e " / l o g i n " = = l o c a t i o n . p a t h n a m e & & l o c a l S t o r a g e . c l e a r ( ) } Enter

异常:
System.ArgumentOutOfRangeException: 该值必须大于或等于零,且必须小于控制台缓冲区在该维度的大小。
参数名: top
实际值是 -1。
   在 System.Console.SetCursorPosition(Int32 left, Int32 top)
   在 Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   在 Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   在 Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   在 Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
   在 Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   在 Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   在 Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Screenshot

Snipaste_2024-07-04_11-51-08 Snipaste_2024-07-04_11-51-21

Environment data

so?

Steps to reproduce

so?

Expected behavior

so?

Actual behavior

so?

github-actions[bot] commented 3 months ago

This issue was already fixed (see #1306). Please upgrade to the 2.3.5 version of PSReadLine from PowerShell Gallery. See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.