@@ -141,6 +141,10 @@ const StatusWithToolTip = ({ po }: { po: FormattedProofObligation }) => {
141141 ) ;
142142} ;
143143
144+ const formatSource = ( source : string | string [ ] ) : string => {
145+ return Array . isArray ( source ) ? source . join ( "\n" ) : source ;
146+ }
147+
144148export const ProofObligationsTable = ( {
145149 headers,
146150 pos,
@@ -154,6 +158,7 @@ export const ProofObligationsTable = ({
154158 id : "id" ,
155159 direction : "ascending" ,
156160 } ) ;
161+ const [ copiedId , setCopiedId ] = useState < number | null > ( null ) ;
157162
158163 const sortedPOs = sortPOs ( pos , sortingState ) ;
159164 const shouldRenderTable = ! ( ( pos . length === 0 ) && posInvalid )
@@ -198,15 +203,36 @@ export const ProofObligationsTable = ({
198203 </ VSCodeDataGridCell >
199204 </ VSCodeDataGridRow >
200205 { openPos . has ( row . id ) ? (
201- < div
202- css = { {
203- width : "100%" ,
204- padding : "1em 0.5em" ,
205- boxSizing : "border-box" ,
206- whiteSpace : "pre-wrap" ,
207- } }
208- >
209- { row . source }
206+ < div css = { { position : "relative" } } >
207+ < VSCodeButton
208+ appearance = "icon"
209+ title = "Copy"
210+ css = { { position : "absolute" , right : "4px" , top : "16px" , transition : "transform 0.15s ease" , } }
211+ onClick = { async ( ) => {
212+ await navigator . clipboard . writeText ( formatSource ( row . source ) ) ;
213+ setCopiedId ( row . id ) ;
214+ setTimeout ( ( ) => setCopiedId ( null ) , 1000 ) ;
215+ } }
216+ >
217+ < span
218+ className = { `codicon ${
219+ copiedId === row . id ? "codicon-check" : "codicon-copy"
220+ } `}
221+ />
222+ </ VSCodeButton >
223+ < pre
224+ css = { {
225+ width : "100%" ,
226+ padding : "1em 0.5em" ,
227+ boxSizing : "border-box" ,
228+ whiteSpace : "pre-wrap" ,
229+ background : "var(--vscode-textBlockQuote-background)" ,
230+ borderRadius : "4px" ,
231+ overflowX : "auto" ,
232+ } }
233+ >
234+ { row . source }
235+ </ pre >
210236 </ div >
211237 ) : null }
212238 </ React . Fragment >
0 commit comments