chore: Prettier fix formatting
This commit is contained in:
1 parent
9de7253998
commit
25cd7cc8e2
106 files changed
+1624
-5278
No files matched your search
@@ -1,10 +1,6 @@
|
||||
import { mentionRegex } from "../../../src/shared/context-mentions"
|
||||
|
||||
export function insertMention(
|
||||
text: string,
|
||||
position: number,
|
||||
value: string,
|
||||
): { newValue: string; mentionIndex: number } {
|
||||
export function insertMention(text: string, position: number, value: string): { newValue: string; mentionIndex: number } {
|
||||
const beforeCursor = text.slice(0, position)
|
||||
const afterCursor = text.slice(position)
|
||||
|
||||
@@ -17,12 +13,7 @@ export function insertMention(
|
||||
if (lastAtIndex !== -1) {
|
||||
// If there's an '@' symbol, replace everything after it with the new mention
|
||||
const beforeMention = text.slice(0, lastAtIndex)
|
||||
newValue =
|
||||
beforeMention +
|
||||
"@" +
|
||||
value +
|
||||
" " +
|
||||
afterCursor.replace(/^[^\s]*/, "")
|
||||
newValue = beforeMention + "@" + value + " " + afterCursor.replace(/^[^\s]*/, "")
|
||||
mentionIndex = lastAtIndex
|
||||
} else {
|
||||
// If there's no '@' symbol, insert the mention at the cursor position
|
||||
@@ -33,10 +24,7 @@ export function insertMention(
|
||||
return { newValue, mentionIndex }
|
||||
}
|
||||
|
||||
export function removeMention(
|
||||
text: string,
|
||||
position: number,
|
||||
): { newText: string; newPosition: number } {
|
||||
export function removeMention(text: string, position: number): { newText: string; newPosition: number } {
|
||||
const beforeCursor = text.slice(0, position)
|
||||
const afterCursor = text.slice(position)
|
||||
|
||||
@@ -45,9 +33,7 @@ export function removeMention(
|
||||
|
||||
if (matchEnd) {
|
||||
// If we're at the end of a mention, remove it
|
||||
const newText =
|
||||
text.slice(0, position - matchEnd[0].length) +
|
||||
afterCursor.replace(" ", "") // removes the first space after the mention
|
||||
const newText = text.slice(0, position - matchEnd[0].length) + afterCursor.replace(" ", "") // removes the first space after the mention
|
||||
const newPosition = position - matchEnd[0].length
|
||||
return { newText, newPosition }
|
||||
}
|
||||
@@ -82,9 +68,7 @@ export function getContextMenuOptions(
|
||||
type: ContextMenuOptionType.File,
|
||||
value: item.value,
|
||||
}))
|
||||
return files.length > 0
|
||||
? files
|
||||
: [{ type: ContextMenuOptionType.NoResults }]
|
||||
return files.length > 0 ? files : [{ type: ContextMenuOptionType.NoResults }]
|
||||
}
|
||||
|
||||
if (selectedType === ContextMenuOptionType.Folder) {
|
||||
@@ -94,9 +78,7 @@ export function getContextMenuOptions(
|
||||
type: ContextMenuOptionType.Folder,
|
||||
value: item.value,
|
||||
}))
|
||||
return folders.length > 0
|
||||
? folders
|
||||
: [{ type: ContextMenuOptionType.NoResults }]
|
||||
return folders.length > 0 ? folders : [{ type: ContextMenuOptionType.NoResults }]
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -112,9 +94,7 @@ export function getContextMenuOptions(
|
||||
if (query.startsWith("http")) {
|
||||
return [{ type: ContextMenuOptionType.URL, value: query }]
|
||||
} else {
|
||||
const matchingItems = queryItems.filter((item) =>
|
||||
item.value?.toLowerCase().includes(lowerQuery),
|
||||
)
|
||||
const matchingItems = queryItems.filter((item) => item.value?.toLowerCase().includes(lowerQuery))
|
||||
|
||||
if (matchingItems.length > 0) {
|
||||
return matchingItems.map((item) => ({
|
||||
|
||||
@@ -6,10 +6,7 @@ import { McpResource, McpResourceTemplate } from "../../../src/shared/mcp"
|
||||
* @param templates Array of URI templates to match against
|
||||
* @returns The matching template or undefined if no match is found
|
||||
*/
|
||||
export function findMatchingTemplate(
|
||||
uri: string,
|
||||
templates: McpResourceTemplate[] = [],
|
||||
): McpResourceTemplate | undefined {
|
||||
export function findMatchingTemplate(uri: string, templates: McpResourceTemplate[] = []): McpResourceTemplate | undefined {
|
||||
return templates.find((template) => {
|
||||
// Convert template to regex pattern
|
||||
const pattern = String(template.uriTemplate)
|
||||
|
||||
@@ -10,26 +10,9 @@ const hljsToTextMate: Record<string, string[]> = {
|
||||
".hljs-variable.language_": ["keyword"],
|
||||
".hljs-title": ["title", "function", "class"],
|
||||
".hljs-title.class_": ["title", "function", "class", "variable"],
|
||||
".hljs-title.class_.inherited__": [
|
||||
"title",
|
||||
"function",
|
||||
"class",
|
||||
"variable",
|
||||
],
|
||||
".hljs-title.function_": [
|
||||
"support.function",
|
||||
"entity.name.function",
|
||||
"title",
|
||||
"function",
|
||||
"class",
|
||||
],
|
||||
".hljs-built_in": [
|
||||
"support.function",
|
||||
"entity.name.function",
|
||||
"title",
|
||||
"function",
|
||||
"class",
|
||||
],
|
||||
".hljs-title.class_.inherited__": ["title", "function", "class", "variable"],
|
||||
".hljs-title.function_": ["support.function", "entity.name.function", "title", "function", "class"],
|
||||
".hljs-built_in": ["support.function", "entity.name.function", "title", "function", "class"],
|
||||
".hljs-name": ["constant"],
|
||||
".hljs-attr": ["variable", "operator", "number"],
|
||||
".hljs-attribute": ["attribute", "variable", "operator", "number"],
|
||||
@@ -85,9 +68,7 @@ function constructTheme(tmTheme: FullColorTheme): Record<string, string> {
|
||||
|
||||
function fallbackTheme() {
|
||||
const styles = getComputedStyle(document.body)
|
||||
const backgroundColor = styles.getPropertyValue(
|
||||
"--vscode-editor-background",
|
||||
)
|
||||
const backgroundColor = styles.getPropertyValue("--vscode-editor-background")
|
||||
const { r, g, b } = parseHexColor(backgroundColor)
|
||||
const avg = (r + g + b) / 3
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import {
|
||||
ApiConfiguration,
|
||||
openRouterDefaultModelId,
|
||||
} from "../../../src/shared/api"
|
||||
import { ApiConfiguration, openRouterDefaultModelId } from "../../../src/shared/api"
|
||||
import { ModelInfo } from "../../../src/shared/api"
|
||||
export function validateApiConfiguration(
|
||||
apiConfiguration?: ApiConfiguration,
|
||||
): string | undefined {
|
||||
export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): string | undefined {
|
||||
if (apiConfiguration) {
|
||||
switch (apiConfiguration.apiProvider) {
|
||||
case "anthropic":
|
||||
@@ -24,10 +19,7 @@ export function validateApiConfiguration(
|
||||
}
|
||||
break
|
||||
case "vertex":
|
||||
if (
|
||||
!apiConfiguration.vertexProjectId ||
|
||||
!apiConfiguration.vertexRegion
|
||||
) {
|
||||
if (!apiConfiguration.vertexProjectId || !apiConfiguration.vertexRegion) {
|
||||
return "You must provide a valid Google Cloud Project ID and Region."
|
||||
}
|
||||
break
|
||||
@@ -47,11 +39,7 @@ export function validateApiConfiguration(
|
||||
}
|
||||
break
|
||||
case "openai":
|
||||
if (
|
||||
!apiConfiguration.openAiBaseUrl ||
|
||||
!apiConfiguration.openAiApiKey ||
|
||||
!apiConfiguration.openAiModelId
|
||||
) {
|
||||
if (!apiConfiguration.openAiBaseUrl || !apiConfiguration.openAiApiKey || !apiConfiguration.openAiModelId) {
|
||||
return "You must provide a valid base URL, API key, and model ID."
|
||||
}
|
||||
break
|
||||
@@ -77,16 +65,11 @@ export function validateModelId(
|
||||
if (apiConfiguration) {
|
||||
switch (apiConfiguration.apiProvider) {
|
||||
case "openrouter":
|
||||
const modelId =
|
||||
apiConfiguration.openRouterModelId ||
|
||||
openRouterDefaultModelId // in case the user hasn't changed the model id, it will be undefined by default
|
||||
const modelId = apiConfiguration.openRouterModelId || openRouterDefaultModelId // in case the user hasn't changed the model id, it will be undefined by default
|
||||
if (!modelId) {
|
||||
return "You must provide a model ID."
|
||||
}
|
||||
if (
|
||||
openRouterModels &&
|
||||
!Object.keys(openRouterModels).includes(modelId)
|
||||
) {
|
||||
if (openRouterModels && !Object.keys(openRouterModels).includes(modelId)) {
|
||||
// even if the model list endpoint failed, extensionstatecontext will always have the default model info
|
||||
return "The model ID you provided is not available. Please choose a different model."
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user