Skip to content

Commit

Permalink
sourcegraph-search: remove unused QUERY_PREFIXES (#77)
Browse files Browse the repository at this point in the history
These are hangovers from the original cody implementation and are no-ops
now.
  • Loading branch information
keegancsmith authored May 23, 2024
1 parent c7a6eef commit 6e3baed
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions provider/sourcegraph-search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import { isError, searchForFileChunks } from './search.js'

const graphqlClient = new SourcegraphGraphQLAPIClient()

/** Used to prefix context queries to indicate a sourcegraph search */
const QUERY_PREFIXES = ['?', 'src:']

/** We always limit our searches to files and a conservatively sized result set */
const SEARCH_QUERY_CONST = 'type:file count:10'

Expand Down Expand Up @@ -101,18 +98,12 @@ function searchQueryFromURL(endpoint: string, url: string): SearchQuery | undefi
}

function searchQueryFromMentionQuery(query: string): SearchQuery {
const userInput = trimFirstPrefix(query, QUERY_PREFIXES)
return {
userInput,
sourcegraphQuery: `${SEARCH_QUERY_CONST} ${userInput}`,
userInput: query,
sourcegraphQuery: `${SEARCH_QUERY_CONST} ${query}`,
}
}

function trimFirstPrefix(s: string, prefixes: string[]): string {
const prefix = prefixes.find(prefix => s.startsWith(prefix)) ?? ''
return s.slice(prefix.length)
}

function trimPrefix(s: string, prefix: string): string {
return s.startsWith(prefix) ? s.slice(prefix.length) : s
}
Expand Down

0 comments on commit 6e3baed

Please sign in to comment.