Skip to content

Commit

Permalink
Get twoslash page feeling good
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jan 11, 2020
1 parent 2ca4a9d commit 61acbb5
Show file tree
Hide file tree
Showing 11 changed files with 452 additions and 286 deletions.
5 changes: 3 additions & 2 deletions packages/gatsby-remark-shiki/src/renderer.ts
Expand Up @@ -41,10 +41,10 @@ export function renderToHTML(lines: Lines, options: Options, twoslash?: TwoSlash
// console.log(tokenPos, token.content.length, filePos)
// Underlining particular words
const findTokenFunc = (start: number) => (e: any) =>
start <= e.character && start + token.content.length <= e.character + e.length
start <= e.character && start + token.content.length >= e.character + e.length

const findTokenDebug = (start: number) => (e: any) => {
const result = start <= e.character && start + token.content.length <= e.character + e.length
const result = start <= e.character && start + token.content.length >= e.character + e.length
// prettier-ignore
console.log(result, start, '<=', e.character, '&&', start + token.content.length, '<=', e.character + e.length)
return result
Expand All @@ -55,6 +55,7 @@ export function renderToHTML(lines: Lines, options: Options, twoslash?: TwoSlash
const queriesInToken = queries.filter(findTokenFunc(tokenPos))

const allTokensByStart = [...errorsInToken, ...lspResponsesInToken, ...queriesInToken]

if (allTokensByStart.length) {
const ranges = allTokensByStart.map(token => {
const range: any = {
Expand Down

0 comments on commit 61acbb5

Please sign in to comment.