mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
only suggest thebibliography once
This commit is contained in:
parent
863128a030
commit
26385718e6
1 changed files with 23 additions and 9 deletions
|
@ -111,15 +111,6 @@ define () ->
|
|||
\\end{frame}
|
||||
"""
|
||||
meta: "env"
|
||||
}, {
|
||||
caption: "\\begin{thebibliography}..."
|
||||
snippet: """
|
||||
\\begin{thebibliography}{$1}
|
||||
\\bibitem{$2}
|
||||
$3
|
||||
\\end{thebibliography}
|
||||
"""
|
||||
meta: "env"
|
||||
}]
|
||||
|
||||
documentSnippet = {
|
||||
|
@ -132,6 +123,16 @@ define () ->
|
|||
meta: "env"
|
||||
}
|
||||
|
||||
bibliographySnippet = {
|
||||
caption: "\\begin{thebibliography}..."
|
||||
snippet: """
|
||||
\\begin{thebibliography}{$1}
|
||||
\\bibitem{$2}
|
||||
$3
|
||||
\\end{thebibliography}
|
||||
"""
|
||||
meta: "env"
|
||||
}
|
||||
staticSnippets.push(documentSnippet)
|
||||
|
||||
parseCustomEnvironments = (text) ->
|
||||
|
@ -163,6 +164,12 @@ define () ->
|
|||
iterations = 0
|
||||
return re.exec(text) != null
|
||||
|
||||
hasBibliographyEnvironment = (text) ->
|
||||
re = /^\\begin{thebibliography}/m
|
||||
envs = []
|
||||
iterations = 0
|
||||
return re.exec(text) != null
|
||||
|
||||
class EnvironmentManager
|
||||
getCompletions: (editor, session, pos, prefix, callback) ->
|
||||
docText = session.getValue()
|
||||
|
@ -175,6 +182,13 @@ define () ->
|
|||
else
|
||||
staticSnippets.push documentSnippet
|
||||
|
||||
if hasBibliographyEnvironment(docText)
|
||||
ind = staticSnippets.indexOf(bibliographySnippet)
|
||||
if ind != -1
|
||||
staticSnippets.splice(ind, 1)
|
||||
else
|
||||
staticSnippets.push bibliographySnippet
|
||||
|
||||
parsedItemsMap = {}
|
||||
for environment in customEnvironments
|
||||
parsedItemsMap[environment.name] = environment
|
||||
|
|
Loading…
Reference in a new issue