[cm6] Improve symbol completion ranking (#12902)
GitOrigin-RevId: 8ccc87c2b86636bd37a3472d36873ade9a190209
This commit is contained in:
@@ -338,16 +338,6 @@ const commandCompletionSource = (context: CompletionContext) => {
|
||||
|
||||
buildAllCompletions(completions, context)
|
||||
|
||||
// ensure that there's only one completion for each label
|
||||
const uniqueCommandCompletions = Array.from(
|
||||
new Map(
|
||||
[
|
||||
...completions.commands,
|
||||
...customCommandCompletions(context, completions.commands),
|
||||
].map(completion => [completion.label, completion])
|
||||
).values()
|
||||
)
|
||||
|
||||
// Unknown commands
|
||||
const prefixMatcher = /^\\[^{\s]*$/
|
||||
const prefixMatch = matchBefore.text.match(prefixMatcher)
|
||||
@@ -356,7 +346,8 @@ const commandCompletionSource = (context: CompletionContext) => {
|
||||
from: matchBefore.from,
|
||||
validFor: prefixMatcher,
|
||||
options: [
|
||||
...uniqueCommandCompletions,
|
||||
...completions.commands,
|
||||
...customCommandCompletions(context, completions.commands),
|
||||
...customEnvironmentCompletions(context),
|
||||
],
|
||||
}
|
||||
@@ -365,7 +356,10 @@ const commandCompletionSource = (context: CompletionContext) => {
|
||||
// anything else (no validFor)
|
||||
return {
|
||||
from: matchBefore.to,
|
||||
options: uniqueCommandCompletions,
|
||||
options: [
|
||||
...completions.commands,
|
||||
...customCommandCompletions(context, completions.commands),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ export function customCommandCompletions(
|
||||
output.push({
|
||||
type: 'cmd',
|
||||
label: item.label,
|
||||
boost: item.count - 10,
|
||||
boost: Math.max(0, item.count - 10),
|
||||
apply: applySnippet(item.snippet),
|
||||
extend: extendOverUnpairedClosingBrace,
|
||||
})
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@ export function buildSnippetCompletions(completions: Completions) {
|
||||
type: item.meta,
|
||||
label: item.caption,
|
||||
boost: item.score,
|
||||
apply: applySnippet(item.snippet),
|
||||
apply:
|
||||
item.snippet === item.caption ? undefined : applySnippet(item.snippet),
|
||||
extend: extendOverUnpairedClosingBrace,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,13 +16,14 @@ import { documentOutline } from './document-outline'
|
||||
import { LaTeXLanguage } from './latex-language'
|
||||
import { documentEnvironmentNames } from './document-environment-names'
|
||||
|
||||
const completionSources = importOverleafModules('sourceEditorCompletionSources')
|
||||
.map((item: any) => item.import.default)
|
||||
.concat(
|
||||
argumentCompletionSources,
|
||||
inCommandCompletionSource,
|
||||
explicitCommandCompletionSource
|
||||
) as CompletionSource[]
|
||||
const completionSources: CompletionSource[] = [
|
||||
...argumentCompletionSources,
|
||||
inCommandCompletionSource,
|
||||
explicitCommandCompletionSource,
|
||||
...importOverleafModules('sourceEditorCompletionSources').map(
|
||||
(item: any) => item.import.default
|
||||
),
|
||||
]
|
||||
|
||||
export const latex = () => {
|
||||
return new LanguageSupport(LaTeXLanguage, [
|
||||
|
||||
Reference in New Issue
Block a user