Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Aug 2, 2024
1 parent 5652137 commit 7855469
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions src/extension/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
} from '../common/constants'
import { Logger } from '../common/logger'
import { SyntaxNode } from 'web-tree-sitter'
import { getParser } from './parser-utils'

const logger = new Logger()

Expand Down Expand Up @@ -450,44 +449,6 @@ export const getSanitizedCommitMessage = (commitMessage: string) => {
export const getNormalisedText = (text: string) =>
text.replace(NORMALIZE_REGEX, ' ')

export async function getDocumentSplitChunks(
content: string,
filePath: string,
chunkSize = 500
): Promise<string[]> {
const parser = await getParser(filePath)

if (!parser) return []

const tree = parser.parse(content)
const chunks: string[] = []

function getSplitChunks(node: SyntaxNode): void {
for (const child of node.children) {
if (child.text.length > 100) {
getSplitChunks(child)
continue
}
chunks.push(child.text)
}
}

getSplitChunks(tree.rootNode)

const finalChunks = []
let buffer = ''
for (const chunk of chunks) {
if (buffer.length + chunk.length < chunkSize) {
buffer += chunk + ' '
} else {
finalChunks.push(buffer.trim())
buffer = chunk + ' '
}
}

return finalChunks
}

export const logStreamOptions = (opts: StreamRequest) => {
logger.log(
`
Expand Down

0 comments on commit 7855469

Please sign in to comment.