diff options
Diffstat (limited to 'extension/src/util')
| -rw-r--r-- | extension/src/util/messenger.ts | 2 | ||||
| -rw-r--r-- | extension/src/util/util.ts | 29 | 
2 files changed, 30 insertions, 1 deletions
| diff --git a/extension/src/util/messenger.ts b/extension/src/util/messenger.ts index 7fd71ddd..3044898e 100644 --- a/extension/src/util/messenger.ts +++ b/extension/src/util/messenger.ts @@ -15,7 +15,7 @@ export abstract class Messenger {    abstract onOpen(callback: () => void): void;    abstract onClose(callback: () => void): void; -   +    abstract onError(callback: () => void): void;    abstract sendAndReceive(messageType: string, data: any): Promise<any>; diff --git a/extension/src/util/util.ts b/extension/src/util/util.ts index d33593e1..dfc10c90 100644 --- a/extension/src/util/util.ts +++ b/extension/src/util/util.ts @@ -1,5 +1,6 @@  import { RangeInFile, SerializedDebugContext } from "../client";  import * as fs from "fs"; +const os = require("os");  function charIsEscapedAtIndex(index: number, str: string): boolean {    if (index === 0) return false; @@ -113,3 +114,31 @@ export function debounced(delay: number, fn: Function) {      }, delay);    };  } + +type Platform = "mac" | "linux" | "windows" | "unknown"; + +function getPlatform(): Platform { +  const platform = os.platform(); +  if (platform === "darwin") { +    return "mac"; +  } else if (platform === "linux") { +    return "linux"; +  } else if (platform === "win32") { +    return "windows"; +  } else { +    return "unknown"; +  } +} + +export function getMetaKeyLabel() { +  const platform = getPlatform(); +  switch (platform) { +    case "mac": +      return "⌘"; +    case "linux": +    case "windows": +      return "^"; +    default: +      return "⌘"; +  } +} | 
