Skip to content

Commit

Permalink
fix: completion only fire for wiki links
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinslin committed Dec 4, 2020
1 parent a726f33 commit f49972e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 3 additions & 6 deletions packages/plugin-core/src/features/completionProvider.ts
Expand Up @@ -11,7 +11,7 @@ import {
workspace,
} from "vscode";
import { Logger } from "../logger";
import { escapeForRegExp, fsPathToRef, RE_WIKI_LINK_ALIAS } from "../utils/md";
import { fsPathToRef } from "../utils/md";
import { DendronWorkspace } from "../workspace";

const padWithZero = (n: number): string => (n < 10 ? "0" + n : String(n));
Expand All @@ -27,12 +27,9 @@ export const provideCompletionItems = (
Logger.debug({ ctx, linePrefix, position, msg: "enter" });

const isResourceAutocomplete = linePrefix.match(/\!\[\[\w*$/);
const isDocsAutocomplete = linePrefix.match(/\[\[\w*$/);
const isAliasAutocomplete = linePrefix.match(
new RegExp(RE_WIKI_LINK_ALIAS, "gi")
);
const isDocsAutocomplete = linePrefix.match(/\[\[[\w\|\.\#]*$/);

if (!isDocsAutocomplete && !isResourceAutocomplete && !isAliasAutocomplete) {
if (!isDocsAutocomplete && !isResourceAutocomplete) {
return undefined;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/plugin-core/src/utils/md.ts
Expand Up @@ -32,7 +32,9 @@ const partialRefPattern = "(\\[\\[)([^\\[\\]]+)";
export const REGEX_FENCED_CODE_BLOCK = /^( {0,3}|\t)```[^`\r\n]*$[\w\W]+?^( {0,3}|\t)``` *$/gm;
export { sortPaths };
const REGEX_CODE_SPAN = /`[^`]*?`/gm;
export const RE_WIKI_LINK_ALIAS = "([^\\[\\]]+?\\|)?";
// export const RE_WIKI_LINK_ALIAS = "([^\\[\\]]+?\\|)?";
// const isResourceAutocomplete = linePrefix.match(/\!\[\[\w*$/);
// const isDocsAutocomplete = linePrefix.match(/\[\[\w*$/);
const uncPathRegex = /^[\\\/]{2,}[^\\\/]+[\\\/]+[^\\\/]+/;
export const otherExts = [
"doc",
Expand Down

0 comments on commit f49972e

Please sign in to comment.