Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Version 5.3.0 (Unreleased)

- Fixed Todo file grouping so same-named roots in multi-root workspaces remain separate in the files view.
- Fixed decoration ranges so repeated captured text highlights the final captured segment instead of an earlier duplicate.
- Fixed dependency indexing so one unreadable or removed Todo file no longer hides dependencies from other workspace files.
- Fixed embedded todo parsing for file paths that start with a number.
- Fixed date-sorted archiving so consecutive finished todos are ordered by their own completion dates.
Expand Down
9 changes: 5 additions & 4 deletions src/utils/regex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* IMPORT */

import * as _ from 'lodash';

/* REGEX */

const Regex = {
Expand All @@ -21,8 +19,11 @@ const Regex = {

match2range(match: RegExpMatchArray) {
const first = match[0],
last = _.findLast(match, (txt) => txt && txt.length) as string, //TSC
start = match.index + first.indexOf(last),
last = match
.slice()
.reverse()
.find((txt) => !!(txt && txt.length)) as string, //TSC
start = match.index + first.lastIndexOf(last),
end = start + last.length;

return { start, end };
Expand Down
10 changes: 10 additions & 0 deletions test/regex.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect } from 'chai';
import Regex from '../src/utils/regex';

describe('Regex utilities', () => {
it('ranges the final capture when its text repeats earlier in the full match', () => {
const match = /(foo)(foo)/.exec('foofoo')!;

expect(Regex.match2range(match)).to.deep.equal({ start: 3, end: 6 });
});
});