Skip to content

Commit

Permalink
Enable autocomplete in an empty wiki link
Browse files Browse the repository at this point in the history
  • Loading branch information
yamnikov-oleg committed Sep 30, 2020
1 parent 431084c commit 658c390
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/NoteWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class NoteWorkspace {
// This will allow us to potentially expose these as settings.
static _rxTagNoAnchors = '\\#[\\w\\-\\_]+'; // used to match tags that appear within lines
static _rxTagWithAnchors = '^\\#[\\w\\-\\_]+$'; // used to match entire words
static _rxWikiLink = '\\[\\[[^sep\\]]+(sep[^sep\\]]+)?\\]\\]'; // [[wiki-link-regex(|with potential pipe)?]] Note: "sep" will be replaced with pipedWikiLinksSeparator on compile
static _rxWikiLink = '\\[\\[[^sep\\]]*(sep[^sep\\]]*)?\\]\\]'; // [[wiki-link-regex(|with potential pipe)?]] Note: "sep" will be replaced with pipedWikiLinksSeparator on compile
static _rxTitle = '(?<=^( {0,3}#[^\\S\\r\\n]+)).+';
static _rxMarkdownWordPattern = '([\\_\\w\\#\\.\\/\\\\]+)'; // had to add [".", "/", "\"] to get relative path completion working and ["#"] to get tag completion working
static _rxFileExtensions = '\\.(md|markdown|mdx|fountain)$';
Expand Down
21 changes: 10 additions & 11 deletions src/Ref.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
A `Ref` is a match for:
- a [[wiki-link]]
Expand Down Expand Up @@ -80,17 +80,16 @@ export function getRefAt(document: vscode.TextDocument, position: vscode.Positio
// keep the end
let r = new vscode.Range(s, e);
ref = document.getText(r);
if (ref) {
// Check for piped wiki-links
ref = NoteWorkspace.cleanPipedWikiLink(ref);

return {
type: RefType.WikiLink,
word: ref, // .replace(/^\[+/, ''),
hasExtension: refHasExtension(ref),
range: r, // range,
};
}
// Check for piped wiki-links
ref = NoteWorkspace.cleanPipedWikiLink(ref);

return {
type: RefType.WikiLink,
word: ref, // .replace(/^\[+/, ''),
hasExtension: refHasExtension(ref),
range: r, // range,
};
}

return NULL_REF;
Expand Down

0 comments on commit 658c390

Please sign in to comment.