@@ -132,7 +132,13 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
132132 if ( 'hint' in parsedLoc ) {
133133 return renderNonLocation ( text , parsedLoc . hint ) ;
134134 } else if ( isWholeFileLoc ( parsedLoc ) || isLineColumnLoc ( parsedLoc ) ) {
135- return renderLocation ( parsedLoc , text , databaseUri , undefined , updateSelectionCallback ( pathNodeKey ) ) ;
135+ return renderLocation (
136+ parsedLoc ,
137+ text ,
138+ databaseUri ,
139+ undefined ,
140+ updateSelectionCallback ( pathNodeKey )
141+ ) ;
136142 } else {
137143 return undefined ;
138144 }
@@ -142,18 +148,33 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
142148 * Render sarif location as a link with the text being simply a
143149 * human-readable form of the location itself.
144150 */
145- function renderSarifLocation ( loc : Sarif . Location , pathNodeKey : Keys . PathNode | undefined ) : JSX . Element | undefined {
151+ function renderSarifLocation (
152+ loc : Sarif . Location ,
153+ pathNodeKey : Keys . PathNode | undefined
154+ ) : JSX . Element | undefined {
146155 const parsedLoc = parseSarifLocation ( loc , sourceLocationPrefix ) ;
147156 if ( 'hint' in parsedLoc ) {
148157 return renderNonLocation ( '[no location]' , parsedLoc . hint ) ;
149158 } else if ( isWholeFileLoc ( parsedLoc ) ) {
150159 const shortLocation = `${ path . basename ( parsedLoc . userVisibleFile ) } ` ;
151160 const longLocation = `${ parsedLoc . userVisibleFile } ` ;
152- return renderLocation ( parsedLoc , shortLocation , databaseUri , longLocation , updateSelectionCallback ( pathNodeKey ) ) ;
161+ return renderLocation (
162+ parsedLoc ,
163+ shortLocation ,
164+ databaseUri ,
165+ longLocation ,
166+ updateSelectionCallback ( pathNodeKey )
167+ ) ;
153168 } else if ( isLineColumnLoc ( parsedLoc ) ) {
154169 const shortLocation = `${ path . basename ( parsedLoc . userVisibleFile ) } :${ parsedLoc . startLine } :${ parsedLoc . startColumn } ` ;
155170 const longLocation = `${ parsedLoc . userVisibleFile } ` ;
156- return renderLocation ( parsedLoc , shortLocation , databaseUri , longLocation , updateSelectionCallback ( pathNodeKey ) ) ;
171+ return renderLocation (
172+ parsedLoc ,
173+ shortLocation ,
174+ databaseUri ,
175+ longLocation ,
176+ updateSelectionCallback ( pathNodeKey )
177+ ) ;
157178 } else {
158179 return undefined ;
159180 }
@@ -163,9 +184,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
163184 return ( e ) => this . toggle ( e , indices ) ;
164185 } ;
165186
166- if ( resultSet . sarif . runs . length === 0 ||
167- resultSet . sarif . runs [ 0 ] . results === undefined ||
168- resultSet . sarif . runs [ 0 ] . results . length === 0 ) {
187+ if ( ! resultSet . sarif . runs ?. [ 0 ] ?. results ?. length ) {
169188 return this . renderNoResults ( ) ;
170189 }
171190
@@ -202,7 +221,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
202221 [ expansionIndex ] ;
203222
204223 rows . push (
205- < tr { ...zebraStripe ( resultIndex ) } >
224+ < tr { ...zebraStripe ( resultIndex ) } key = { resultIndex } >
206225 < td className = "vscode-codeql__icon-cell vscode-codeql__dropdown-cell" onMouseDown = { toggler ( indices ) } >
207226 { indicator }
208227 </ td >
@@ -223,7 +242,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
223242 if ( currentResultExpanded ) {
224243 const indicator = currentPathExpanded ? octicons . chevronDown : octicons . chevronRight ;
225244 rows . push (
226- < tr { ...zebraStripe ( resultIndex ) } >
245+ < tr { ...zebraStripe ( resultIndex ) } key = { ` ${ resultIndex } - ${ pathIndex } ` } >
227246 < td className = "vscode-codeql__icon-cell" > < span className = "vscode-codeql__vertical-rule" > </ span > </ td >
228247 < td className = "vscode-codeql__icon-cell vscode-codeql__dropdown-cell" onMouseDown = { toggler ( [ expansionIndex ] ) } > { indicator } </ td >
229248 < td className = "vscode-codeql__text-center" colSpan = { 3 } >
@@ -249,7 +268,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
249268 const stepIndex = pathNodeIndex + 1 ; // Convert to 1-based
250269 const zebraIndex = resultIndex + stepIndex ;
251270 rows . push (
252- < tr className = { isSelected ? 'vscode-codeql__selected-path-node' : undefined } >
271+ < tr className = { isSelected ? 'vscode-codeql__selected-path-node' : undefined } key = { ` ${ resultIndex } - ${ pathIndex } - ${ pathNodeIndex } ` } >
253272 < td className = "vscode-codeql__icon-cell" > < span className = "vscode-codeql__vertical-rule" > </ span > </ td >
254273 < td className = "vscode-codeql__icon-cell" > < span className = "vscode-codeql__vertical-rule" > </ span > </ td >
255274 < td { ...selectableZebraStripe ( isSelected , zebraIndex , 'vscode-codeql__path-index-cell' ) } > { stepIndex } </ td >
@@ -264,9 +283,13 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
264283 } ) ;
265284
266285 if ( numTruncatedResults > 0 ) {
267- rows . push ( < tr > < td colSpan = { 5 } style = { { textAlign : 'center' , fontStyle : 'italic' } } >
268- Too many results to show at once. { numTruncatedResults } result(s) omitted.
269- </ td > </ tr > ) ;
286+ rows . push (
287+ < tr key = "truncatd-message" >
288+ < td colSpan = { 5 } style = { { textAlign : 'center' , fontStyle : 'italic' } } >
289+ Too many results to show at once. { numTruncatedResults } result(s) omitted.
290+ </ td >
291+ </ tr >
292+ ) ;
270293 }
271294
272295 return < table className = { className } >
0 commit comments