[BUG] Crash: Failed to find wrapped line in text

Resolved 💬 2 comments Opened Mar 14, 2026 by jacobcxdev Closed Apr 12, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

  ERROR  Failed to find wrapped line in text

 /$bunfs/root/src/entrypoints/cli.js:1111:170

 1108 `),q=Math.min(Math.max(0,_-1),T.length-1),R=0;for(let K=0;K<q;K++)R+=(T[K]?.length??0)+1;return new
 :   y4(this.measuredText,R,0)}endOfFile(){return new y4(this.measuredText,this.text.length,0)}get text(){return
     this.measuredText.text}get columns(){return this.measuredText.columns+1}getPosition(){return
     this.measuredText.getPositionFromOffset(this.offset)}getOffset(_){return
     this.measuredText.getOffsetFromPosition(_)}findCharacter(_,T,q=1){let
     R=this.text,K=T==="f"||T==="t",$=T==="t"||T==="T",O=0;if(K){let
     A=this.measuredText.nextOffset(this.offset);while(A<R.length){if(this.graphemeAt(A)===_){if(O++,O===q)return $?Math.max(th
     is.offset,this.measuredText.prevOffset(A)):A}A=this.measuredText.nextOffset(A)}}else{if(this.offset===0)return null;let
     A=this.measuredText.prevOffset(this.offset);while(A>=0){if(this.graphemeAt(A)===_){if(O++,O===q)return
     $?Math.min(this.offset,this.measuredText.nextOffset(A)):A}if(A===0)break;A=this.measuredText.prevOffset(A)}}return
     null}}class x2T{text;startOffset;isPrecededByNewline;endsWithNewline;constructor(_,T,q,R=!1){this.text=_;this.startOffset=
     T;this.isPrecededByNewline=q;this.endsWithNewline=R}equals(_){return
     this.text===_.text&&this.startOffset===_.startOffset}get length(){return
     this.text.length+(this.endsWithNewline?1:0)}}class Un6{columns;_wrappedLines;text;navigationCache;graphemeBoundaries;const
     ructor(_,T){this.columns=T;this.text=_.normalize("NFC"),this.navigationCache=new Map}get
     wrappedLines(){if(!this._wrappedLines)this._wrappedLines=this.measureWrappedText();return
     this._wrappedLines}getGraphemeBoundaries(){if(!this.graphemeBoundaries){this.graphemeBoundaries=[];for(let{index:_}of
     $f().segment(this.text))this.graphemeBoundaries.push(_);this.graphemeBoundaries.push(this.text.length)}return this.graphem
     eBoundaries}wordBoundariesCache;getWordBoundaries(){if(!this.wordBoundariesCache){this.wordBoundariesCache=[];for(let _ of
      k_6().segment(this.text))this.wordBoundariesCache.push({start:_.index,end:_.index+_.segment.length,isWordLike:_.isWordLik
     e??!1})}return this.wordBoundariesCache}binarySearchBoundary(_,T,q){let
     R=0,K=_.length-1,$=q?this.text.length:0;while(R<=K){let O=Math.floor((R+K)/2),A=_[O];if(A===void
     0)break;if(q)if(A>T)$=A,K=O-1;else R=O+1;else if(A<T)$=A,R=O+1;else K=O-1}return
     $}stringIndexToDisplayWidth(_,T){if(T<=0)return 0;if(T>=_.length)return Zq(_);return
     Zq(_.substring(0,T))}displayWidthToStringIndex(_,T){if(T<=0)return 0;if(!_)return 0;if(_===this.text)return
     this.offsetAtDisplayWidth(T);let q=0,R=0;for(let{segment:K,index:$}of $f().segment(_)){let
     O=Zq(K);if(q+O>T)break;q+=O,R=$+K.length}return R}offsetAtDisplayWidth(_){if(_<=0)return 0;let
     T=0,q=this.getGraphemeBoundaries();for(let R=0;R<q.length-1;R++){let K=q[R],$=q[R+1];if(K===void 0||$===void
     0)continue;let O=this.text.substring(K,$),A=Zq(O);if(T+A>_)return K;T+=A}return this.text.length}measureWrappedText(){let
     _=g9_(this.text,this.columns,{hard:!0,trim:!1}),T=[],q=0,R=-1,K=_.split(`
 1109: `);for(let $=0;$<K.length;$++){let O=K[$],A=(H)=>$===0||H>0&&this.text[H-1]===`
 1110: `;if(O.length===0)if(R=this.text.indexOf(`
 1111 `,R+1),R!==-1){let H=R,z=!0;T.push(new x2T(O,H,A(H),!0))}else{let H=this.text.length;T.push(new
 :   x2T(O,H,A(H),!1))}else{let H=this.text.indexOf(O,q);if(H===-1)throw Error("Failed to find wrapped line in
     text");q=H+O.length;let z=H+O.length,j=z<this.text.length&&this.text[z]===`
 1112 `;if(j)R=z;T.push(new x2T(O,H,A(H),j))}}return T}getWrappedText(){return
 :   this.wrappedLines.map((_)=>_.isPrecededByNewline?_.text:_.text.trimStart())}getWrappedLines(){return
     this.wrappedLines}getLine(_){let T=this.wrappedLines;return
     T[Math.max(0,Math.min(_,T.length-1))]}getOffsetFromPosition(_){let
     T=this.getLine(_.line);if(T.text.length===0&&T.endsWithNewline)return T.startOffset;let
     q=T.isPrecededByNewline?0:T.text.length-T.text.trimStart().length,R=_.column+q,K=this.displayWidthToStringIndex(T.text,R),
     $=T.startOffset+K,O=T.startOffset+T.text.length,A=O,H=Zq(T.text);if(T.endsWithNewline&&_.column>H)A=O+1;return
     Math.min($,A)}getLineLength(_){let T=this.getLine(_);return Zq(T.text)}getPositionFromOffset(_){let
     T=this.wrappedLines;for(let K=0;K<T.length;K++){let $=T[K],O=T[K+1];if(_>=$.startOffset&&(!O||_<O.startOffset)){let
     A=_-$.startOffset,H;if($.isPrecededByNewline)H=this.stringIndexToDisplayWidth($.text,A);else{let
     z=$.text.length-$.text.trimStart().length;if(A<z)H=0;else{let
     j=$.text.trimStart(),f=A-z;H=this.stringIndexToDisplayWidth(j,f)}}return{line:K,column:Math.max(0,H)}}}let
     q=T.length-1,R=this.wrappedLines[q];return{line:q,column:Zq(R.text)}}get lineCount(){return
     this.wrappedLines.length}withCache(_,T){let q=this.navigationCache.get(_);if(q!==void 0)return q;let R=T();return
     this.navigationCache.set(_,R),R}nextOffset(_){return this.withCache(`next:${_}`,()=>{let
     T=this.getGraphemeBoundaries();return this.binarySearchBoundary(T,_,!0)})}prevOffset(_){if(_<=0)return 0;return
     this.withCache(`prev:${_}`,()=>{let T=this.getGraphemeBoundaries();return
     this.binarySearchBoundary(T,_,!1)})}snapToGraphemeBoundary(_){if(_<=0)return 0;if(_>=this.text.length)return
     this.text.length;let T=this.getGraphemeBoundaries(),q=0,R=T.length-1;while(q<R){let K=q+R+1>>1;if(T[K]<=_)q=K;else
     R=K-1}return T[q]}}var imR=10,iV,b2T=0,JGq=!1,cn6=0,WGq=0,I2T=!1,nmR,dB_,aU=(_)=>nmR.test(_),g2T=(_)=>dB_.test(_),ss=(_)=>
     _.length>0&&!g2T(_)&&!aU(_);var pR_=X(()=>{ezT();AK();Bv();iV=[];nmR=/^[\p{L}\p{N}\p{M}_]$/u,dB_=/\s/});function XGq(){let
      _=OT().existsSync(Fn6.join(MT(),"CLAUDE.md")),T=nn6(MT());return[{key:"workspace",text:"Ask Claude to create a new app or
      clone a repository",isComplete:!1,isCompletable:!0,isEnabled:T},{key:"claudemd",text:"Run /init to create a CLAUDE.md
     file with instructions for Claude",isComplete:_,isCompletable:!0,isEnabled:!T}]}function Qn6(){return
     XGq().filter(({isCompletable:_,isEnabled:T})=>_&&T).every(({isComplete:_})=>_)}function
     lJ_(){if(iH().hasCompletedProjectOnboarding)return;if(Qn6())nH((_)=>({..._,hasCompletedProjectOnboarding:!0}))}function
     in6(){nH((_)=>({..._,projectOnboardingSeenCount:_.projectOnboardingSeenCount+1}))}var Fn6,ln6;var
     FB_=X(()=>{Cq();G6();t8();I8();Q7();Fn6=require("path");ln6=$q(()=>{if(Qn6()||iH().projectOnboardingSeenCount>=4||process.
     env.IS_DEMO)return!1;return!0})});function
     rmR(_){iT((T)=>({...T,appleTerminalSetupInProgress:!0,appleTerminalBackupPath:_}))}function
     iJ_(){iT((_)=>({..._,appleTerminalSetupInProgress:!1}))}function amR(){let
     _=fT();return{inProgress:_.appleTerminalSetupInProgress??!1,backupPath:_.appleTerminalBackupPath||null}}function
     nJ_(){return an6.join(rn6.homedir(),"Library","Preferences","com.apple.Terminal.plist")}async function on6(){let
     _=nJ_(),T=`${_}.bak`;try{let{code:q}=await Aq("defaults",["export","com.apple.Terminal",_]);if(q!==0)return null;try{await
      kGq.stat(_)}catch{return null}return await Aq("defaults",["export","com.apple.Terminal",T]),rmR(T),T}catch(q){return
     K_(q),null}}async function d2T(){let{inProgress:_,backupPath:T}=amR();if(!_)return{status:"no_backup"};if(!T)return
     iJ_(),{status:"no_backup"};try{await kGq.stat(T)}catch{return iJ_(),{status:"no_backup"}}try{let{code:q}=await
     Aq("defaults",["import","com.apple.Terminal",T]);if(q!==0)return{status:"failed",backupPath:T};return await
     Aq("killall",["cfprefsd"]),iJ_(),{status:"restored"}}catch(q){return K_(Error(`Failed to restore Terminal.app settings
     with: ${q}`)),iJ_(),{status:"failed",backupPath:T}}}var rn6,an6,kGq;var
     MGq=X(()=>{V9();yT();Cq();rn6=require("os"),an6=require("path"),kGq=require("fs/promises")});function omR(){let
     _=process.env.SHELL||"",T=sn6.homedir(),q=Qm.join(T,".claude");if(_.endsWith("/zsh")||_.endsWith("/zsh.exe")){let
     R=Qm.join(q,"completion.zsh");return{name:"zsh",rcFile:Qm.join(T,".zshrc"),cacheFile:R,completionLine:`[[ -f "${R}" ]] &&
     source "${R}"`,shellFlag:"zsh"}}if(_.endsWith("/bash")||_.endsWith("/bash.exe")){let
     R=Qm.join(q,"completion.bash");return{name:"bash",rcFile:Qm.join(T,".bashrc"),cacheFile:R,completionLine:`[ -f "${R}" ] &&
      source "${R}"`,shellFlag:"bash"}}if(_.endsWith("/fish")||_.endsWith("/fish.exe")){let
     R=process.env.XDG_CONFIG_HOME||Qm.join(T,".config"),K=Qm.join(q,"completion.fish");return{name:"fish",rcFile:Qm.join(R,"fi
     sh","config.fish"),cacheFile:K,completionLine:`[ -f "${K}" ] && source "${K}"`,shellFlag:"fish"}}return null}async
     function GGq(){let _=omR();if(!_)return;y(`update: Regenerating ${_.name} completion cache`);let
     T=process.argv[1]||"claude";if((await Aq(T,["completion",_.shellFlag,"--output",_.cacheFile])).code!==0){y(`update: Failed
      to regenerate ${_.name} completion cache`);return}y(`update: Regenerated ${_.name} completion cache at
     ${_.cacheFile}`)}var sn6,Qm;var hGq=X(()=>{z4_();OU();HT();V9();yT();sn6=require("os"),Qm=require("path")});var
     Tr6={};kT(Tr6,{shouldOfferTerminalSetup:()=>rJ_,setupTerminal:()=>F2T,markBackslashReturnUsed:()=>VGq,isShiftEnterKeyBindi
     ngInstalled:()=>yGq,hasUsedBackslashReturn:()=>vGq,getNativeCSIuTerminalDisplayName:()=>NGq,call:()=>tmR});function
     smR(){let _=process.env.VSCODE_GIT_ASKPASS_MAIN??"",T=process.env.PATH??"";return
     _.includes(".vscode-server")||_.includes(".cursor-server")||_.includes(".windsurf-server")||T.includes(".vscode-server")||
     T.includes(".cursor-server")||T.includes(".windsurf-server")}function NGq(){if(!nq.terminal||!(nq.terminal in c2T))return
     null;return c2T[nq.terminal]??null}function nV(_){if(!jM())return
     _;return`\x1B]8;;${_r6.pathToFileURL(_).href}\x07${_}\x1B]8;;\x07`}function rJ_(){return
     sU.platform()==="darwin"&&nq.terminal==="Apple_Terminal"||nq.terminal==="vscode"||nq.terminal==="cursor"||nq.terminal==="w
     indsurf"||nq.terminal==="alacritty"||nq.terminal==="zed"}async function F2T(_){let
     T="";switch(nq.terminal){case"Apple_Terminal":T=await emR(_);break;case"vscode":T=await
     ZGq("VSCode",_);break;case"cursor":T=await ZGq("Cursor",_);break;case"windsurf":T=await
     ZGq("Windsurf",_);break;case"alacritty":T=await _pR(_);break;case"zed":T=await TpR(_);break;case null:break}return
     iT((q)=>{if(["vscode","cursor","windsurf","alacritty","zed"].includes(nq.terminal??"")){if(q.shiftEnterKeyBindingInstalled
     ===!0)return q;return{...q,shiftEnterKeyBindingInstalled:!0}}else
     if(nq.terminal==="Apple_Terminal"){if(q.optionAsMetaKeyInstalled===!0)return
     q;return{...q,optionAsMetaKeyInstalled:!0}}return q}),lJ_(),T}function yGq(){return
     fT().shiftEnterKeyBindingInstalled===!0}function vGq(){return fT().hasUsedBackslashReturn===!0}function
     VGq(){if(!fT().hasUsedBackslashReturn)iT((T)=>({...T,hasUsedBackslashReturn:!0}))}async function
     tmR(_,T,q){if(nq.terminal&&nq.terminal in c2T){let K=`Shift+Enter is natively supported in ${c2T[nq.terminal]}.

 1113:
 1114 No configuration needed. Just use Shift+Enter to add newlines.`;return _(K),null}if(!rJ_()){let K=nq.terminal||"your
 :   current terminal",$=Sq(),O="";if($==="macos")O=`   \u2022 macOS: Apple Terminal

 - measureWrappedText (/$bunfs/root/src/entrypoints/cli.js:1111:170)
 - wrappedLines (/$bunfs/root/src/entrypoints/cli.js:1108:1524)
 - getPositionFromOffset (/$bunfs/root/src/entrypoints/cli.js:1112:729)
 - render (/$bunfs/root/src/entrypoints/cli.js:1100:1197)
 - OET (/$bunfs/root/src/entrypoints/cli.js:3961:859)
 - v4 (/$bunfs/root/src/entrypoints/cli.js:3965:5052)
 - CK (/$bunfs/root/src/entrypoints/cli.js:624:21011)
 - NH (/$bunfs/root/src/entrypoints/cli.js:624:39553)
 - lj (/$bunfs/root/src/entrypoints/cli.js:624:50243)
 - UC (/$bunfs/root/src/entrypoints/cli.js:624:86985)

What Should Happen?

It shouldn't crash.

Steps to Reproduce

No idea. It just happened.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.75

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗