@@ -22,6 +22,7 @@ interface FileCardProps {
2222 searchOptions : SearchOptions ;
2323 activeMatchIndexInFile : number | null ;
2424 onCopyPath : ( path : string ) => void ;
25+ wordWrap ?: boolean ;
2526}
2627
2728const IconButton : React . FC < { icon : string , title : string , onClick : ( ) => void , disabled ?: boolean , text ?: string } > = ( { icon, title, onClick, disabled, text} ) => (
@@ -49,7 +50,7 @@ function buildSearchRegex(query: string, options: SearchOptions): RegExp | null
4950const FileCard : React . FC < FileCardProps > = ( {
5051 file, isEditing, onStartEdit, onSaveEdit, onCancelEdit,
5152 isMarkdown, isMarkdownPreview, onToggleMarkdownPreview, onShowToast, fontSize,
52- searchQuery, searchOptions, activeMatchIndexInFile, onCopyPath
53+ searchQuery, searchOptions, activeMatchIndexInFile, onCopyPath, wordWrap
5354} ) => {
5455 const [ editText , setEditText ] = React . useState ( file . content ) ;
5556 const codeRef = React . useRef < HTMLElement > ( null ) ;
@@ -211,7 +212,7 @@ const FileCard: React.FC<FileCardProps> = ({
211212 { lineNumbers }
212213 </ pre >
213214 < div className = "relative flex-1" >
214- < pre className = " py-3 pr-3 whitespace-pre-wrap break-words bg-light-bg dark:bg-dark-bg" > < code
215+ < pre className = { ` py-3 pr-3 bg-light-bg dark:bg-dark-bg ${ wordWrap ? ' whitespace-pre-wrap break-words' : 'whitespace-pre overflow-x-auto' } ` } > < code
215216 ref = { codeRef }
216217 className = { `language-${ file . language } hljs` }
217218 /> </ pre >
@@ -237,13 +238,14 @@ interface CodeViewProps {
237238 searchOptions : SearchOptions ;
238239 activeMatchIndexInFile : number | null ;
239240 onCopyPath : ( path : string ) => void ;
241+ wordWrap ?: boolean ;
240242}
241243
242244const CodeView : React . FC < CodeViewProps > = ( props ) => {
243245 const {
244246 selectedFile, editingPath, onStartEdit, onSaveEdit, onCancelEdit,
245247 markdownPreviewPaths, onToggleMarkdownPreview, onShowToast, fontSize,
246- searchQuery, searchOptions, activeMatchIndexInFile, onCopyPath
248+ searchQuery, searchOptions, activeMatchIndexInFile, onCopyPath, wordWrap
247249 } = props ;
248250
249251 if ( ! selectedFile ) {
@@ -278,6 +280,7 @@ const CodeView: React.FC<CodeViewProps> = (props) => {
278280 searchOptions = { searchOptions }
279281 activeMatchIndexInFile = { activeMatchIndexInFile }
280282 onCopyPath = { onCopyPath }
283+ wordWrap = { wordWrap }
281284 />
282285 </ motion . div >
283286 </ div >
0 commit comments