Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autostart functionality #14

Merged
merged 1 commit into from
Jun 27, 2020
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
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
},
"license": "MIT",
"activationEvents": [
"onLanguage:markdown",
"onCommand:markdown-links.showGraph"
],
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
"command": "markdown-links.showGraph",
"title": "Show Graph"
"title": "Markdown Links: Show Graph"
}
],
"configuration": {
Expand All @@ -49,6 +50,11 @@
"type": "string",
"default": "\\d{14}",
"description": "Regular extension used to find file IDs. First match of this regex in file contents, excluding [[links]], will be used as the file ID. This file ID can be used for wiki-style links."
},
"markdown-links.autoStart": {
"type": "boolean",
"default": false,
"description": "Should Markdown Links automatically start when a markdown file is opened."
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as vscode from "vscode";
import { TextDecoder } from "util";
import * as path from "path";
import { parseFile, parseDirectory, learnFileId } from "./parsing";
import { filterNonExistingEdges, getColumnSetting } from "./utils";
import { filterNonExistingEdges, getColumnSetting, getConfiguration } from "./utils";
import { Graph } from "./types";

const watch = (
Expand Down Expand Up @@ -141,6 +141,12 @@ export function activate(context: vscode.ExtensionContext) {
watch(context, panel, graph);
})
);

const shouldAutoStart = getConfiguration("autoStart");

if (shouldAutoStart) {
vscode.commands.executeCommand("markdown-links.showGraph");
}
}

async function getWebviewContent(
Expand Down