Make the Terminal entry in the @mentions configurable (#6126)
JetBrains doesn't support @terminal mentions, so don't show it in the mentions context menu.
This commit is contained in:
1 parent
0cefe107b8
commit
0d13ae1fa4
3 files changed
+23
-12
No files matched your search
@@ -3,12 +3,14 @@
|
||||
"messageEncoding": "none",
|
||||
"showNavbar": false,
|
||||
"postMessageHandler": "vscode",
|
||||
"togglePlanActKeys": "Meta+Shift+a"
|
||||
"togglePlanActKeys": "Meta+Shift+a",
|
||||
"supportsTerminalMentions": true
|
||||
},
|
||||
"standalone": {
|
||||
"messageEncoding": "json",
|
||||
"showNavbar": true,
|
||||
"postMessageHandler": "standalone",
|
||||
"togglePlanActKeys": "Meta+Shift+p"
|
||||
"togglePlanActKeys": "Meta+Shift+p",
|
||||
"supportsTerminalMentions": false
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ export interface PlatformConfig {
|
||||
encodeMessage: MessageEncoder
|
||||
decodeMessage: MessageDecoder
|
||||
togglePlanActKeys: string
|
||||
supportsTerminalMentions: boolean
|
||||
}
|
||||
|
||||
// Internal type for JSON structure (not exported)
|
||||
@@ -15,6 +16,7 @@ type PlatformConfigJson = {
|
||||
showNavbar: boolean
|
||||
postMessageHandler: "vscode" | "standalone"
|
||||
togglePlanActKeys: string
|
||||
supportsTerminalMentions: boolean
|
||||
}
|
||||
|
||||
type PlatformConfigs = Record<string, PlatformConfigJson>
|
||||
@@ -81,6 +83,7 @@ export const PLATFORM_CONFIG: PlatformConfig = {
|
||||
encodeMessage: messageEncoders[selectedConfig.messageEncoding],
|
||||
decodeMessage: messageDecoders[selectedConfig.messageEncoding],
|
||||
togglePlanActKeys: selectedConfig.togglePlanActKeys,
|
||||
supportsTerminalMentions: selectedConfig.supportsTerminalMentions,
|
||||
}
|
||||
|
||||
type MessageEncoding = "none" | "json"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { mentionRegex } from "@shared/context-mentions"
|
||||
import { Fzf } from "fzf"
|
||||
import * as path from "path"
|
||||
import { PLATFORM_CONFIG } from "@/config/platform.config"
|
||||
|
||||
export interface SearchResult {
|
||||
path: string
|
||||
@@ -96,17 +97,22 @@ export interface ContextMenuQueryItem {
|
||||
description?: string
|
||||
}
|
||||
|
||||
const DEFAULT_CONTEXT_MENU_OPTIONS = [
|
||||
ContextMenuOptionType.URL,
|
||||
ContextMenuOptionType.Problems,
|
||||
ContextMenuOptionType.Terminal,
|
||||
ContextMenuOptionType.Git,
|
||||
ContextMenuOptionType.Folder,
|
||||
ContextMenuOptionType.File,
|
||||
]
|
||||
function getContextMenuEntries(): ContextMenuOptionType[] {
|
||||
const entries = [
|
||||
ContextMenuOptionType.URL,
|
||||
ContextMenuOptionType.Problems,
|
||||
ContextMenuOptionType.Git,
|
||||
ContextMenuOptionType.Folder,
|
||||
ContextMenuOptionType.File,
|
||||
]
|
||||
if (PLATFORM_CONFIG.supportsTerminalMentions) {
|
||||
entries.splice(2, 0, ContextMenuOptionType.Terminal)
|
||||
}
|
||||
return entries
|
||||
}
|
||||
|
||||
export function getContextMenuOptionIndex(option: ContextMenuOptionType) {
|
||||
return DEFAULT_CONTEXT_MENU_OPTIONS.findIndex((item) => item === option)
|
||||
return getContextMenuEntries().findIndex((item) => item === option)
|
||||
}
|
||||
|
||||
export function getContextMenuOptions(
|
||||
@@ -163,7 +169,7 @@ export function getContextMenuOptions(
|
||||
return commits.length > 0 ? [workingChanges, ...commits] : [workingChanges]
|
||||
}
|
||||
|
||||
return DEFAULT_CONTEXT_MENU_OPTIONS.map((type) => ({ type }))
|
||||
return getContextMenuEntries().map((type) => ({ type }))
|
||||
}
|
||||
|
||||
const lowerQuery = query.toLowerCase()
|
||||
|
||||
Reference in new issue
Block a user