From 919c9c253efeefe5ab6835fa874872c3289fe6f0 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Mon, 5 Oct 2020 20:23:40 +0530 Subject: [PATCH] feat(source): SourceMapping - Add token also to map This token will be helpful to find completion record from AST token. When you click on source code, this will be used. --- src/logic/sourceMapping.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logic/sourceMapping.tsx b/src/logic/sourceMapping.tsx index 0db53d7..f4b5240 100644 --- a/src/logic/sourceMapping.tsx +++ b/src/logic/sourceMapping.tsx @@ -1,6 +1,7 @@ import { Token } from "../types/prism-types"; export interface TMappingELement { + token: Token; start: number; end: number; ref: { current: HTMLElement | null }; @@ -20,6 +21,7 @@ export const sourceMapping: TSourceMapping = { lastEnd: 0, registerToken(t: Token) { const obj: TMappingELement = { + token: t, start: this.lastEnd, end: this.lastEnd + t.content.length, ref: { current: null }, @@ -27,8 +29,6 @@ export const sourceMapping: TSourceMapping = { this.mappingArray.push(obj); this.lastEnd = this.mappingArray[this.mappingArray.length - 1].end; - console.log(obj, t); - return function updateHTMLElement(ele) { obj.ref.current = ele; };