mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
scanner: set initial offset
This commit is contained in:
@@ -41,10 +41,10 @@ class MultiLineStream {
|
||||
private len: number;
|
||||
private position: number;
|
||||
|
||||
constructor(source: string) {
|
||||
constructor(source: string, position: number) {
|
||||
this.source = source;
|
||||
this.len = source.length;
|
||||
this.position = 0;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public eos(): boolean {
|
||||
@@ -201,9 +201,9 @@ export interface Scanner {
|
||||
getScannerState(): ScannerState;
|
||||
}
|
||||
|
||||
export function createScanner(input: string, initialState: ScannerState = ScannerState.Content) : Scanner {
|
||||
export function createScanner(input: string, initialOffset = 0, initialState: ScannerState = ScannerState.Content) : Scanner {
|
||||
|
||||
let stream = new MultiLineStream(input);
|
||||
let stream = new MultiLineStream(input, initialOffset);
|
||||
let state = initialState;
|
||||
let tokenOffset: number = 0;
|
||||
let tokenType: number = void 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ suite('HTML Scanner', () => {
|
||||
|
||||
let scannerState = ScannerState.Content;
|
||||
for (let t of tests) {
|
||||
let scanner = createScanner(t.input, scannerState);
|
||||
let scanner = createScanner(t.input, 0, scannerState);
|
||||
let tokenType = scanner.scan();
|
||||
let actual : Token[] = [];
|
||||
while (tokenType !== TokenType.EOS) {
|
||||
|
||||
Reference in New Issue
Block a user