Skip to content

Commit

Permalink
Merge pull request #22 from houkanshan/fix-uri-path
Browse files Browse the repository at this point in the history
Fix windows specific bugs while finding ref for tag
  • Loading branch information
kortina authored May 17, 2020
2 parents efd89cf + 110809e commit 76beb23
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class WorkspaceTagList {
)
.map((f) => {
// read file, get all words beginning with #, add to Set
readFile(f.path, (err, data) => {
readFile(f.fsPath, (err, data) => {
let allWords = (data || '').toString().split(/\s/);
let tags = allWords.filter((w) => w.match(TAG_REGEX_WITH_ANCHORS));
tags.map((t) => this.TAG_WORD_SET.add(t));
Expand Down Expand Up @@ -93,7 +93,7 @@ export class ReferenceSearch {
if (!queryWord) {
return [];
}
let lines = data.split(/[\r\n]/);
let lines = data.split(/\r?\n/);
lines.map((line, lineNum) => {
let charNum = 0;
// https://stackoverflow.com/questions/17726904/javascript-splitting-a-string-yet-preserving-the-spaces
Expand Down Expand Up @@ -133,7 +133,7 @@ export class ReferenceSearch {
// TODO: parameterize extensions. Add $ to end?
(f) => f.scheme == 'file' && f.path.match(/\.(md|markdown)/i)
);
let paths = files.map((f) => f.path);
let paths = files.map((f) => f.fsPath);
let fileBuffers = await Promise.all(paths.map((p) => fsp.readFile(p)));
fileBuffers.map((data, i) => {
let path = files[i].path;
Expand Down Expand Up @@ -328,7 +328,7 @@ class MarkdownDefinitionProvider implements vscode.DefinitionProvider {
const filename = selectedWord;
// there should be exactly 1 file with name = selectedWord
files = (await workspace.findFiles('**/*')).filter((f) => {
return basename(f.path) == filename;
return basename(f.fsPath) == filename;
});
}
// If we did not find any files in the workspace,
Expand Down

0 comments on commit 76beb23

Please sign in to comment.