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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### Fixes

- Fixed constant CPU use and typing lag in workspaces with many Markdown notes. Dependency warnings now reuse the notes already loaded for the sidebars and rescan only edited files; reopening every note after each edit made VS Code close and reopen them in a loop. Unrelated setting changes no longer reload every task file, sidebar and badge refreshes reuse unchanged scans, and the new `todo.refreshDelay` setting controls how long these refreshes wait after an edit. [#306](https://github.com/vycdev/vscode-todo-plus-two/issues/306)
- Encoded terminal periods in generated relative file links so filenames ending in a period survive link parsing and archive moves.

### Version 5.4.0

Expand Down
4 changes: 3 additions & 1 deletion src/utils/file-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const makeRelativeFileLink = (documentPath: string, targetPath: string):
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
)
)
.join('/');
.join('/')
// A literal terminal period is stripped as sentence punctuation when links are read.
.replace(/\.$/, '%2E');
return `file://${encodedPath.startsWith('../') ? '' : './'}${encodedPath}`;
};

Expand Down
11 changes: 11 additions & 0 deletions test/file-links.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ describe('Relative file links', () => {
expect(findRelativeFileLinks(text, documentPath)[0].targetPath).to.equal(target);
});

it('round-trips generated links to filenames ending in a period', () => {
const target = path.join(workspacePath, 'todos', 'report.');
const text = makeRelativeFileLink(documentPath, target);
expect(text).to.equal('file://./report%2E');
expect(findRelativeFileLinks(text, documentPath)[0].targetPath).to.equal(target);
const archivePath = path.join(workspacePath, 'ARCHIVE.TODO');
const rebased = rebaseRelativeFileLinks(text, documentPath, archivePath);
expect(rebased).to.equal('file://./todos/report%2E');
expect(findRelativeFileLinks(rebased, archivePath)[0].targetPath).to.equal(target);
});

it('keeps relative attachment targets when a task moves to a workspace-root archive', () => {
const archivePath = path.join(workspacePath, 'ARCHIVE.TODO');
const text =
Expand Down
Loading