mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3304 from overleaf/ns-env-autocomplete-nesting
Parse nested environments for autocomplete suggestion GitOrigin-RevId: 1ddfc0e0129801f203084a74c586031ffe0d5bb9
This commit is contained in:
parent
dff706bf67
commit
57e9cf2829
1 changed files with 6 additions and 4 deletions
|
@ -146,20 +146,22 @@ const parseCustomEnvironments = function(text) {
|
||||||
|
|
||||||
const parseBeginCommands = function(text) {
|
const parseBeginCommands = function(text) {
|
||||||
let match
|
let match
|
||||||
const re = /^\\begin{(\w+)}.*\n([\t ]*).*$/gm
|
const re = /^([\t ]*)\\begin{(\w+)}.*\n([\t ]*)/gm
|
||||||
const result = []
|
const result = []
|
||||||
let iterations = 0
|
let iterations = 0
|
||||||
while ((match = re.exec(text))) {
|
while ((match = re.exec(text))) {
|
||||||
|
const whitespaceAlignment = match[3].replace(match[1] || '', '')
|
||||||
if (
|
if (
|
||||||
!Array.from(Environments.all).includes(match[1]) &&
|
!Array.from(Environments.all).includes(match[2]) &&
|
||||||
match[1] !== 'document'
|
match[2] !== 'document'
|
||||||
) {
|
) {
|
||||||
result.push({ name: match[1], whitespace: match[2] })
|
result.push({ name: match[2], whitespace: whitespaceAlignment })
|
||||||
iterations += 1
|
iterations += 1
|
||||||
if (iterations >= 1000) {
|
if (iterations >= 1000) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
re.lastIndex = match.index + 1
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue