Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional absolute char indexing for highlighting #2584

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix issue regarding failing test cases
groups.pop() was called without considering the
number of capturing groups within. This caused
some issues with the end bound of word matching
being popped and removed from the array.
  • Loading branch information
AgentHagu committed Jan 20, 2025
commit f679edbf0271fb0d37eedb096a26a4b46c2c1deb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ export class HighlightRuleComponent {
const linesliceWordMatch = compString.match(LINESLICE_WORD_REGEX);
const sliceMatch = linesliceCharMatch || linesliceWordMatch;
if (sliceMatch) {
// There are four capturing groups: [full match, line number, start bound, end bound]
// There are four/five capturing groups: [full match, line number, start bound,
// end bound,highlight spaces]
const groups = sliceMatch.slice(1); // discard full match

const lineNumber = HighlightRuleComponent
.isValidLineNumber(groups.shift() ?? '', 1, lines.length, lineNumberOffset);
if (!lineNumber) return null;

let highlightSpaces = false;
if (sliceMatch === linesliceCharMatch) {
highlightSpaces = groups.pop() === '+';
}

const isUnbounded = groups.every(x => x === '');
const highlightSpaces = groups.pop() === '+';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

if (isUnbounded) {
return new HighlightRuleComponent(lineNumber, true, []);
}
Expand Down
Loading