diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-07-15 15:06:32 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-07-15 15:06:32 -0700 | 
| commit | 45ee33f7fd84c0bc49d35d9d1a7a3a8e9f6addd7 (patch) | |
| tree | da7d7898a63178a4d6da73dcb08722a9a358634a /extension/src | |
| parent | 48e5c8001e897eb37493357087410ee8f98217fa (diff) | |
| download | sncontinue-45ee33f7fd84c0bc49d35d9d1a7a3a8e9f6addd7.tar.gz sncontinue-45ee33f7fd84c0bc49d35d9d1a7a3a8e9f6addd7.tar.bz2 sncontinue-45ee33f7fd84c0bc49d35d9d1a7a3a8e9f6addd7.zip | |
use correct label for meta key
Diffstat (limited to 'extension/src')
| -rw-r--r-- | extension/src/diffs.ts | 3 | ||||
| -rw-r--r-- | extension/src/lang-server/codeLens.ts | 7 | ||||
| -rw-r--r-- | extension/src/util/util.ts | 29 | 
3 files changed, 35 insertions, 4 deletions
| diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index d04f9bdb..9d0c9fe7 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -3,6 +3,7 @@ import * as path from "path";  import * as fs from "fs";  import * as vscode from "vscode";  import { extensionContext, ideProtocolClient } from "./activation/activate"; +import { getMetaKeyLabel } from "./util/util";  interface DiffInfo {    originalFilepath: string; @@ -86,7 +87,7 @@ class DiffManager {      ) {        vscode.window          .showInformationMessage( -          "Accept (⌘⇧↩) or reject (⌘⇧⌫) at the top of the file.", +          `Accept (${getMetaKeyLabel()}⇧↩) or reject (${getMetaKeyLabel()}⇧⌫) at the top of the file.`,            "Got it",            "Don't show again"          ) diff --git a/extension/src/lang-server/codeLens.ts b/extension/src/lang-server/codeLens.ts index 1cfef5d5..ba80e557 100644 --- a/extension/src/lang-server/codeLens.ts +++ b/extension/src/lang-server/codeLens.ts @@ -3,6 +3,7 @@ import { editorToSuggestions, editorSuggestionsLocked } from "../suggestions";  import * as path from "path";  import * as os from "os";  import { DIFF_DIRECTORY, diffManager } from "../diffs"; +import { getMetaKeyLabel } from "../util/util";  class SuggestionsCodeLensProvider implements vscode.CodeLensProvider {    public provideCodeLenses(      document: vscode.TextDocument, @@ -35,7 +36,7 @@ class SuggestionsCodeLensProvider implements vscode.CodeLensProvider {        if (codeLenses.length === 2) {          codeLenses.push(            new vscode.CodeLens(range, { -            title: "(⌘⇧↩/⌘⇧⌫ to accept/reject all)", +            title: `(${getMetaKeyLabel()}⇧↩/${getMetaKeyLabel()}⇧⌫ to accept/reject all)`,              command: "",            })          ); @@ -60,12 +61,12 @@ class DiffViewerCodeLensProvider implements vscode.CodeLensProvider {        }        codeLenses.push(          new vscode.CodeLens(range, { -          title: "Accept All ✅ (⌘⇧↩)", +          title: `Accept All ✅ (${getMetaKeyLabel()}⇧↩)`,            command: "continue.acceptDiff",            arguments: [document.uri.fsPath],          }),          new vscode.CodeLens(range, { -          title: "Reject All ❌ (⌘⇧⌫)", +          title: `Reject All ❌ (${getMetaKeyLabel()}⇧⌫)`,            command: "continue.rejectDiff",            arguments: [document.uri.fsPath],          }) 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 "⌘"; +  } +} | 
