@@ -906,6 +906,20 @@ class SplitBuffer {
906
906
this . buffer += this . separators [ 0 ] ; // Append a separator to the end to ensure the last line is returned.
907
907
}
908
908
909
+ /**
910
+ * A version of startsWith that isn't overriden by a broken version of ms-python.
911
+ *
912
+ * The definition comes from
913
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
914
+ * which is CC0/public domain
915
+ *
916
+ * See https://github.com/github/vscode-codeql/issues/802 for more context as to why we need it.
917
+ */
918
+ private static startsWith ( s : string , searchString : string , position : number ) : boolean {
919
+ const pos = position > 0 ? position | 0 : 0 ;
920
+ return s . substring ( pos , pos + searchString . length ) === searchString ;
921
+ }
922
+
909
923
/**
910
924
* Extract the next full line from the buffer, if one is available.
911
925
* @returns The text of the next available full line (without the separator), or `undefined` if no
@@ -914,7 +928,7 @@ class SplitBuffer {
914
928
public getNextLine ( ) : string | undefined {
915
929
while ( this . searchIndex <= ( this . buffer . length - this . maxSeparatorLength ) ) {
916
930
for ( const separator of this . separators ) {
917
- if ( this . buffer . startsWith ( separator , this . searchIndex ) ) {
931
+ if ( SplitBuffer . startsWith ( this . buffer , separator , this . searchIndex ) ) {
918
932
const line = this . buffer . substr ( 0 , this . searchIndex ) ;
919
933
this . buffer = this . buffer . substr ( this . searchIndex + separator . length ) ;
920
934
this . searchIndex = 0 ;
0 commit comments