Skip to content

Commit

Permalink
Remove getIncludedBibs
Browse files Browse the repository at this point in the history
This function is a duplicate of getIncludedBib from cache.ts
  • Loading branch information
jlelong committed Dec 26, 2024
1 parent 98b208c commit 8fa5f33
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions src/completion/completer/citation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function provide(uri: vscode.Uri, line: string, position: vscode.Position): Comp
const label = configuration.get('intellisense.citation.label') as string
const fields = readCitationFormat(configuration)
const range: vscode.Range | undefined = computeFilteringRange(line, position)
return updateAll(getIncludedBibs(lw.root.file.path)).map(item => {
return updateAll(lw.cache.getIncludedBib(lw.root.file.path)).map(item => {
// Compile the completion item label
switch(label) {
case 'bibtex key':
Expand Down Expand Up @@ -131,7 +131,7 @@ function browser(args?: CompletionArgs) {
const configuration = vscode.workspace.getConfiguration('latex-workshop', args?.uri)
const label = configuration.get('intellisense.citation.label') as string
const fields = readCitationFormat(configuration, label)
void vscode.window.showQuickPick(updateAll(getIncludedBibs(lw.root.file.path)).map(item => {
void vscode.window.showQuickPick(updateAll(lw.cache.getIncludedBib(lw.root.file.path)).map(item => {
return {
label: item.fields.title ? trimMultiLineString(item.fields.title) : '',
description: item.key,
Expand Down Expand Up @@ -178,33 +178,6 @@ function getItem(key: string, configurationScope?: vscode.ConfigurationScope): C
return entry
}

/**
* Returns the array of the paths of `.bib` files referenced from `file`.
*
* @param file The path of a LaTeX file. If `undefined`, the keys of `bibEntries` are used.
* @param visitedTeX Internal use only.
*/
function getIncludedBibs(file?: string, visitedTeX: string[] = []): string[] {
if (file === undefined) {
// Only happens when rootFile is undefined
return Array.from(data.bibEntries.keys())
}
const cache = lw.cache.get(file)
if (cache === undefined) {
return []
}
let bibs = Array.from(cache.bibfiles)
visitedTeX.push(file)
for (const child of cache.children) {
if (visitedTeX.includes(child.filePath)) {
// Already included
continue
}
bibs = Array.from(new Set(bibs.concat(getIncludedBibs(child.filePath, visitedTeX))))
}
return bibs
}

/**
* Returns aggregated bib entries from `.bib` files and bibitems defined on LaTeX files included in the root file.
*
Expand Down

0 comments on commit 8fa5f33

Please sign in to comment.