Commit 5d83fdc0 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Fix bug in source position injection

Change-Id: If8faa3c7c0324fc9d0a2704533278828c62d5b91
Notry: true
Bug: v8:8128, v8:7327
Reviewed-on: https://chromium-review.googlesource.com/c/1319765Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57286}
parent 201a0c67
......@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {Source,SourceResolver,sourcePositionToStringKey} from "../src/source-resolver"
import {SelectionBroker} from "../src/selection-broker"
import {View} from "../src/view"
import {MySelection} from "../src/selection"
import {anyToString,ViewElements} from "../src/util"
import { Source, SourceResolver, sourcePositionToStringKey } from "../src/source-resolver"
import { SelectionBroker } from "../src/selection-broker"
import { View } from "../src/view"
import { MySelection } from "../src/selection"
import { anyToString, ViewElements } from "../src/util"
export enum CodeMode {
MAIN_SOURCE = "main function",
......@@ -220,10 +220,13 @@ export class CodeView extends View {
insertSourcePositions(currentSpan, lineNumber, pos, end, adjust) {
const view = this;
const sps = this.sourceResolver.sourcePositionsInRange(this.source.sourceId, pos - adjust, end);
let offset = 0;
for (const sourcePosition of sps) {
this.sourceResolver.addAnyPositionToLine(lineNumber, sourcePosition);
const textnode = currentSpan.tagName == 'SPAN' ? currentSpan.firstChild : currentSpan;
const replacementNode = textnode.splitText(Math.max(0, sourcePosition.scriptOffset - pos));
const textnode = currentSpan.tagName == 'SPAN' ? currentSpan.lastChild : currentSpan;
const splitLength = Math.max(0, sourcePosition.scriptOffset - pos - offset);
offset += splitLength;
const replacementNode = textnode.splitText(splitLength);
const span = document.createElement('span');
span.setAttribute("scriptOffset", sourcePosition.scriptOffset);
span.classList.add("source-position")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment