mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
[cm6] Improve symbol completion ranking (#12902)
GitOrigin-RevId: 8ccc87c2b86636bd37a3472d36873ade9a190209
This commit is contained in:
parent
009a108c71
commit
b1929cf16d
6 changed files with 26 additions and 30 deletions
16
package-lock.json
generated
16
package-lock.json
generated
|
@ -3145,9 +3145,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/@codemirror/autocomplete": {
|
||||
"version": "6.6.0",
|
||||
"resolved": "git+ssh://git@github.com/overleaf/codemirror-autocomplete.git#cd13c2c15a6f89b207f7cc4523e38fd5ef0efc47",
|
||||
"integrity": "sha512-Uf8Tv/wLUmPyxTwxrp/+t+f5sognQs+qHyQ+AvCFhS1wWa2Tw9+Ko/84EsPXQpYwTgN8xvejBCSHlRzubogHLA==",
|
||||
"version": "6.6.1",
|
||||
"resolved": "git+ssh://git@github.com/overleaf/codemirror-autocomplete.git#4514fd21c6c9219f5c23a6a675ad843bb7a5b2bd",
|
||||
"integrity": "sha512-3xD9M0e5cw0XsC7mMfRy+vKcOup7Nno4J3r0aTvwWqsUlQYBzT0R3sBEn6y+gHdpIpuSEx+jKIGKiqBsWI8czg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
|
@ -35165,7 +35165,7 @@
|
|||
"@babel/preset-env": "^7.14.5",
|
||||
"@babel/preset-react": "^7.14.5",
|
||||
"@babel/preset-typescript": "^7.16.0",
|
||||
"@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#cd13c2c15a6f89b207f7cc4523e38fd5ef0efc47",
|
||||
"@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#4514fd21c6c9219f5c23a6a675ad843bb7a5b2bd",
|
||||
"@codemirror/commands": "^6.2.3",
|
||||
"@codemirror/lang-markdown": "^6.1.1",
|
||||
"@codemirror/language": "^6.6.0",
|
||||
|
@ -39926,9 +39926,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"@codemirror/autocomplete": {
|
||||
"version": "git+ssh://git@github.com/overleaf/codemirror-autocomplete.git#cd13c2c15a6f89b207f7cc4523e38fd5ef0efc47",
|
||||
"integrity": "sha512-Uf8Tv/wLUmPyxTwxrp/+t+f5sognQs+qHyQ+AvCFhS1wWa2Tw9+Ko/84EsPXQpYwTgN8xvejBCSHlRzubogHLA==",
|
||||
"from": "@codemirror/autocomplete@github:overleaf/codemirror-autocomplete#cd13c2c15a6f89b207f7cc4523e38fd5ef0efc47",
|
||||
"version": "git+ssh://git@github.com/overleaf/codemirror-autocomplete.git#4514fd21c6c9219f5c23a6a675ad843bb7a5b2bd",
|
||||
"integrity": "sha512-3xD9M0e5cw0XsC7mMfRy+vKcOup7Nno4J3r0aTvwWqsUlQYBzT0R3sBEn6y+gHdpIpuSEx+jKIGKiqBsWI8czg==",
|
||||
"from": "@codemirror/autocomplete@github:overleaf/codemirror-autocomplete#4514fd21c6c9219f5c23a6a675ad843bb7a5b2bd",
|
||||
"requires": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
|
@ -44845,7 +44845,7 @@
|
|||
"@babel/preset-react": "^7.14.5",
|
||||
"@babel/preset-typescript": "^7.16.0",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#cd13c2c15a6f89b207f7cc4523e38fd5ef0efc47",
|
||||
"@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#4514fd21c6c9219f5c23a6a675ad843bb7a5b2bd",
|
||||
"@codemirror/commands": "^6.2.3",
|
||||
"@codemirror/lang-markdown": "^6.1.1",
|
||||
"@codemirror/language": "^6.6.0",
|
||||
|
|
|
@ -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),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -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,
|
||||
const completionSources: CompletionSource[] = [
|
||||
...argumentCompletionSources,
|
||||
inCommandCompletionSource,
|
||||
explicitCommandCompletionSource
|
||||
) as CompletionSource[]
|
||||
explicitCommandCompletionSource,
|
||||
...importOverleafModules('sourceEditorCompletionSources').map(
|
||||
(item: any) => item.import.default
|
||||
),
|
||||
]
|
||||
|
||||
export const latex = () => {
|
||||
return new LanguageSupport(LaTeXLanguage, [
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
"@babel/preset-env": "^7.14.5",
|
||||
"@babel/preset-react": "^7.14.5",
|
||||
"@babel/preset-typescript": "^7.16.0",
|
||||
"@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#cd13c2c15a6f89b207f7cc4523e38fd5ef0efc47",
|
||||
"@codemirror/autocomplete": "github:overleaf/codemirror-autocomplete#4514fd21c6c9219f5c23a6a675ad843bb7a5b2bd",
|
||||
"@codemirror/commands": "^6.2.3",
|
||||
"@codemirror/lang-markdown": "^6.1.1",
|
||||
"@codemirror/language": "^6.6.0",
|
||||
|
|
Loading…
Reference in a new issue