Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Fix display bug with multi-matches lines
Browse files Browse the repository at this point in the history
  • Loading branch information
PoignardAzur committed Apr 14, 2018
1 parent 0c83a1a commit 4638934
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/project/result-row-view.js
Expand Up @@ -112,16 +112,14 @@ class MatchRowView {
}

generatePreviewNode({matches, replacePattern, regex}) {
const lineText = matches[0].lineText
const subnodes = [];

let prevEnd = 0;
for (const match of matches) {
const range = Range.fromObject(match.range);
const matchStart = range.start.column - match.lineTextOffset;
const matchEnd = range.end.column - match.lineTextOffset;

const prefix = match.lineText.slice(prevEnd, matchStart);
const prefix = match.lineText.slice(prevEnd - match.lineTextOffset, matchStart);

let replacementText = ''
if (replacePattern && regex) {
Expand All @@ -147,10 +145,11 @@ class MatchRowView {
replacementText
)
);
prevEnd = matchEnd;
prevEnd = range.end.column;
}

const suffix = lineText.slice(prevEnd);
const lastMatch = matches[matches.length - 1];
const suffix = lastMatch.lineText.slice(prevEnd - lastMatch.lineTextOffset);

return $.span(
{className: 'preview'},
Expand Down

0 comments on commit 4638934

Please sign in to comment.