@@ -5,6 +5,7 @@ import { RawResultsSortState, QueryMetadata, SortDirection } from '../pure/inter
55import { assertNever } from '../pure/helpers-pure' ;
66import { ResultSet } from '../pure/interface-types' ;
77import { vscode } from './vscode-api' ;
8+ import { convertNonPrintableChars } from '../text-utils' ;
89
910export interface ResultTableProps {
1011 resultSet : ResultSet ;
@@ -37,9 +38,6 @@ export const oddRowClassName = 'vscode-codeql__result-table-row--odd';
3738export const pathRowClassName = 'vscode-codeql__result-table-row--path' ;
3839export const selectedRowClassName = 'vscode-codeql__result-table-row--selected' ;
3940
40- const CONTROL_CODE = '\u001F' . codePointAt ( 0 ) ! ;
41- const CONTROL_LABEL = '\u2400' . codePointAt ( 0 ) ! ;
42-
4341export function jumpToLocationHandler (
4442 loc : ResolvableLocationValue ,
4543 databaseUri : string ,
@@ -70,30 +68,6 @@ export function openFile(filePath: string): void {
7068 } ) ;
7169}
7270
73- function convertedNonprintableChars ( label : string ) {
74- // If the label was empty, use a placeholder instead, so the link is still clickable.
75- if ( ! label ) {
76- return '[empty string]' ;
77- } else if ( label . match ( / ^ \s + $ / ) ) {
78- return `[whitespace: "${ label } "]` ;
79- } else {
80- /**
81- * If the label contains certain non-printable characters, loop through each
82- * character and replace it with the cooresponding unicode control label.
83- */
84- const convertedLabelArray : any [ ] = [ ] ;
85- for ( let i = 0 ; i < label . length ; i ++ ) {
86- const labelCheck = label . codePointAt ( i ) ! ;
87- if ( labelCheck <= CONTROL_CODE ) {
88- convertedLabelArray [ i ] = String . fromCodePoint ( labelCheck + CONTROL_LABEL ) ;
89- } else {
90- convertedLabelArray [ i ] = label . charAt ( i ) ;
91- }
92- }
93- return convertedLabelArray . join ( '' ) ;
94- }
95- }
96-
9771/**
9872 * Render a location as a link which when clicked displays the original location.
9973 */
@@ -105,7 +79,7 @@ export function renderLocation(
10579 callback ?: ( ) => void
10680) : JSX . Element {
10781
108- const displayLabel = convertedNonprintableChars ( label ! ) ;
82+ const displayLabel = convertNonPrintableChars ( label ! ) ;
10983
11084 if ( loc === undefined ) {
11185 return < span > { displayLabel } </ span > ;
0 commit comments