Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix off by one issue in getToken character tracking

+5 -5
+5 -5
src/token.ts
··· 21 21 let cPos = template.pos + 1; 22 22 23 23 let foundToken: Token | undefined = undefined; 24 - for (let i = 0; i < input.length; i++) { 25 - const lPos = cPos; 26 - const stream = new CharacterStream(input[i]); 24 + for (let line = 0; line < input.length; line++) { 25 + const lPos = cPos - 1; 26 + const stream = new CharacterStream(input[line]); 27 27 while (!stream.eol()) { 28 28 const token = parser.token(stream, state); 29 29 const string = stream.current(); ··· 34 34 lPos + stream.getCurrentPosition() >= cursorPosition 35 35 ) { 36 36 foundToken = { 37 - line: i, 37 + line, 38 38 start: stream.getStartOfToken() + 1, 39 39 end: stream.getCurrentPosition(), 40 40 string, ··· 45 45 } 46 46 } 47 47 48 - cPos += input[i].length + 1; 48 + cPos += input[line].length + 1; 49 49 } 50 50 51 51 return foundToken;