mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Streamline the project metadata context provider (#19384)
GitOrigin-RevId: 0b75635cb9141983827dfd0fa6a58b6182d47f22
This commit is contained in:
+1
-7
@@ -16,13 +16,7 @@ export function buildLabelCompletions(
|
||||
return
|
||||
}
|
||||
|
||||
const uniqueLabels = new Set(
|
||||
Object.values(metadata.documents)
|
||||
.map(doc => doc.labels)
|
||||
.flat(1)
|
||||
)
|
||||
|
||||
for (const label of uniqueLabels) {
|
||||
for (const label of metadata.labels) {
|
||||
completions.labels.push({
|
||||
type: 'label',
|
||||
label,
|
||||
|
||||
+16
-16
@@ -21,24 +21,24 @@ export function buildPackageCompletions(
|
||||
return
|
||||
}
|
||||
|
||||
const uniquePackageNames = new Set<string>(packageNames)
|
||||
|
||||
// package names and commands from packages in the project
|
||||
for (const doc of Object.values(metadata.documents)) {
|
||||
for (const [packageName, commands] of Object.entries(doc.packages)) {
|
||||
uniquePackageNames.add(packageName)
|
||||
|
||||
for (const item of commands) {
|
||||
completions.commands.push({
|
||||
type: item.meta,
|
||||
label: item.caption,
|
||||
apply: applySnippet(item.snippet),
|
||||
extend: extendOverUnpairedClosingBrace,
|
||||
})
|
||||
}
|
||||
}
|
||||
// commands from packages in the project
|
||||
for (const command of metadata.commands) {
|
||||
completions.commands.push({
|
||||
type: command.meta,
|
||||
label: command.caption,
|
||||
apply: applySnippet(command.snippet),
|
||||
extend: extendOverUnpairedClosingBrace,
|
||||
})
|
||||
}
|
||||
|
||||
const uniquePackageNames = new Set<string>(packageNames)
|
||||
|
||||
// package names from packages in the project
|
||||
for (const packageName of metadata.packageNames) {
|
||||
uniquePackageNames.add(packageName)
|
||||
}
|
||||
|
||||
// exclude package names that are already in this document
|
||||
const existingPackageNames = findExistingPackageNames(context)
|
||||
|
||||
for (const item of uniquePackageNames) {
|
||||
|
||||
Reference in New Issue
Block a user