Fixed language and Dropped updates (#23)

* Fixed language and updating problems

* Fixed language and Dropped updates

* renovation

* also, once again forgot to remove the debugging
This commit is contained in:
Zachary Kohnen 2018-01-03 13:11:21 -05:00 committed by Crawl
parent 02bf6acfb1
commit 1a9dbc3023
2 changed files with 950 additions and 866 deletions

View file

@ -1,4 +1,87 @@
{ {
"knownLanguages": [
"as",
"asp",
"assembly",
"ahk",
"autoit",
"bower",
"brainfuck",
"gemfile",
"c",
"cpp",
"csharp",
"clojure",
"cmake",
"coffee",
"crystal",
"css",
"less",
"stylus",
"scss",
"d",
"dart",
"manifest",
"delphi",
"docker",
"ejs",
"elm",
"erlang",
"elixir",
"fsharp",
"git",
"go",
"gradle",
"graphql",
"handlebars",
"haskell",
"html",
"haxe",
"pug",
"jar",
"java",
"julia",
"js",
"jsx",
"json",
"kotlin",
"lisp",
"lua",
"makefile",
"markdown",
"objc",
"ocaml",
"pascal",
"perl",
"php",
"powershell",
"python",
"r",
"ruby",
"rust",
"scala",
"shell",
"sql",
"svg",
"swift",
"tex",
"toml",
"ts",
"tsx",
"twig",
"text",
"vb",
"vba",
"vbhtml",
"vbproj",
"vcxproj",
"vscodeignore",
"vue",
"yaml",
"yarn",
"bat"
],
"knownExtentions": {
".swf": { ".swf": {
"image": "as" "image": "as"
}, },
@ -854,4 +937,5 @@
".reg": { ".reg": {
"image": "bat" "image": "bat"
} }
}
} }

View file

@ -12,7 +12,10 @@ import {
workspace, workspace,
WorkspaceFolder WorkspaceFolder
} from 'vscode'; } from 'vscode';
const languages = require('./data/languages.json'); const lang = require('./data/languages.json');
const knownExtentions: { [x: string]: {image: string}} = lang.knownExtentions;
const knownLanguages: string[] = lang.knownLanguages;
// Define the RPC variable and its type. // Define the RPC variable and its type.
let rpc: Client; let rpc: Client;
@ -92,12 +95,6 @@ function initRPC(clientID: string): void {
// Set the activity once on ready // Set the activity once on ready
setTimeout(() => rpc.setActivity(activity), 500); setTimeout(() => rpc.setActivity(activity), 500);
const workspaceElapsedTime = Boolean(config.get('workspaceElapsedTime')); const workspaceElapsedTime = Boolean(config.get('workspaceElapsedTime'));
eventHandlers.add(workspace.onDidChangeTextDocument(() => setActivity(workspaceElapsedTime)))
.add(workspace.onDidOpenTextDocument(() => setActivity(workspaceElapsedTime)))
.add(workspace.onDidCloseTextDocument(() => setActivity(workspaceElapsedTime)))
.add(debug.onDidChangeActiveDebugSession(() => setActivity()))
.add(debug.onDidStartDebugSession(() => setActivity()))
.add(debug.onDidTerminateDebugSession(() => setActivity()));
// Make sure to listen to the close event and dispose and destroy everything accordingly. // Make sure to listen to the close event and dispose and destroy everything accordingly.
rpc.transport.once('close', async () => { rpc.transport.once('close', async () => {
if (!config.get('enabled')) return; if (!config.get('enabled')) return;
@ -110,7 +107,10 @@ function initRPC(clientID: string): void {
}); });
// Update the user's activity to the `activity` variable. // Update the user's activity to the `activity` variable.
activityTimer = setInterval(() => rpc.setActivity(activity), 15000); activityTimer = setInterval(() => {
setActivity(workspaceElapsedTime);
rpc.setActivity(activity);
}, 15000);
}); });
// Log in to the RPC Client, and check whether or not it errors. // Log in to the RPC Client, and check whether or not it errors.
@ -157,14 +157,14 @@ function setActivity(workspaceElapsedTime: boolean = false): void {
lastKnownFileName = window.activeTextEditor ? window.activeTextEditor.document.fileName : null; lastKnownFileName = window.activeTextEditor ? window.activeTextEditor.document.fileName : null;
const fileName: string = window.activeTextEditor ? basename(window.activeTextEditor.document.fileName) : null; const fileName: string = window.activeTextEditor ? basename(window.activeTextEditor.document.fileName) : null;
const largeImageKey = window.activeTextEditor const largeImageKey: any = window.activeTextEditor
? languages[Object.keys(languages).find(key => { ? knownExtentions[Object.keys(knownExtentions).find(key => {
if (key.startsWith('.') && fileName.endsWith(key)) return true; if (key.startsWith('.') && fileName.endsWith(key)) return true;
const match = key.match(/^\/(.*)\/([mgiy]+)$/); const match = key.match(/^\/(.*)\/([mgiy]+)$/);
if (!match) return false; if (!match) return false;
const regex = new RegExp(match[1], match[2]); const regex = new RegExp(match[1], match[2]);
return regex.test(fileName); return regex.test(fileName);
})] })] || (knownLanguages.includes(window.activeTextEditor.document.languageId) ? window.activeTextEditor.document.languageId : null)
: 'vscode-big'; : 'vscode-big';
// Get the previous activity start timestamp (if available) to preserve workspace elapsed time // Get the previous activity start timestamp (if available) to preserve workspace elapsed time