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 | |
parent | 48e5c8001e897eb37493357087410ee8f98217fa (diff) | |
download | sncontinue-45ee33f7fd84c0bc49d35d9d1a7a3a8e9f6addd7.tar.gz sncontinue-45ee33f7fd84c0bc49d35d9d1a7a3a8e9f6addd7.tar.bz2 sncontinue-45ee33f7fd84c0bc49d35d9d1a7a3a8e9f6addd7.zip |
use correct label for meta key
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 3 | ||||
-rw-r--r-- | extension/react-app/src/components/StepContainer.tsx | 7 | ||||
-rw-r--r-- | extension/react-app/src/util/index.ts | 17 | ||||
-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 |
6 files changed, 58 insertions, 8 deletions
diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 754c9445..f11e07af 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -13,6 +13,7 @@ import HeaderButtonWithText from "./HeaderButtonWithText"; import { DocumentPlus } from "@styled-icons/heroicons-outline"; import { HighlightedRangeContext } from "../../../schema/FullState"; import { postVscMessage } from "../vscode"; +import { getMetaKeyLabel } from "../util"; // #region styled components const mainInputFontSize = 13; @@ -286,7 +287,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { <div className="flex px-2" ref={divRef} hidden={!downshiftProps.isOpen}> <MainTextInput disabled={props.disabled} - placeholder="Ask a question, give instructions, or type '/' to see slash commands. ⌘⏎ to edit." + placeholder={`Ask a question, give instructions, or type '/' to see slash commands. ${getMetaKeyLabel()}⏎ to edit.`} {...getInputProps({ onChange: (e) => { const target = e.target as HTMLTextAreaElement; diff --git a/extension/react-app/src/components/StepContainer.tsx b/extension/react-app/src/components/StepContainer.tsx index 7f23e333..93bdbc89 100644 --- a/extension/react-app/src/components/StepContainer.tsx +++ b/extension/react-app/src/components/StepContainer.tsx @@ -17,6 +17,7 @@ import { StopCircle } from "@styled-icons/heroicons-solid"; import { HistoryNode } from "../../../schema/HistoryNode"; import HeaderButtonWithText from "./HeaderButtonWithText"; import MarkdownPreview from "@uiw/react-markdown-preview"; +import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../util"; interface StepContainerProps { historyNode: HistoryNode; @@ -217,7 +218,11 @@ function StepContainer(props: StepContainerProps) { e.stopPropagation(); props.onDelete(); }} - text={props.historyNode.active ? "Stop (⌘⌫)" : "Delete"} + text={ + props.historyNode.active + ? `Stop (${getMetaKeyLabel()}⌫)` + : "Delete" + } > {props.historyNode.active ? ( <StopCircle size="1.6em" onClick={props.onDelete} /> diff --git a/extension/react-app/src/util/index.ts b/extension/react-app/src/util/index.ts index ad711321..c4168e13 100644 --- a/extension/react-app/src/util/index.ts +++ b/extension/react-app/src/util/index.ts @@ -1,6 +1,6 @@ type Platform = "mac" | "linux" | "windows" | "unknown"; -function getPlatform(): Platform { +export function getPlatform(): Platform { const platform = window.navigator.platform.toUpperCase(); if (platform.indexOf("MAC") >= 0) { return "mac"; @@ -13,7 +13,7 @@ function getPlatform(): Platform { } } -function isMetaEquivalentKeyPressed(event: { +export function isMetaEquivalentKeyPressed(event: { metaKey: boolean; ctrlKey: boolean; }): boolean { @@ -28,3 +28,16 @@ function isMetaEquivalentKeyPressed(event: { return event.metaKey; } } + +export function getMetaKeyLabel(): string { + const platform = getPlatform(); + switch (platform) { + case "mac": + return "⌘"; + case "linux": + case "windows": + return "^"; + default: + return "⌘"; + } +} 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 "⌘"; + } +} |