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.
This commit is contained in:
2020-10-05 20:23:40 +05:30
parent 83760b66f9
commit 919c9c253e
+2 -2
View File
@@ -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;
};