mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Don't lock up on very long lined documents
This commit is contained in:
parent
0aaeb6671e
commit
40704b486e
1 changed files with 6 additions and 2 deletions
|
@ -15,8 +15,12 @@ module.exports = ProjectRootDocManager =
|
|||
return (cb)->
|
||||
rootDocId = null
|
||||
for line in doc.lines || []
|
||||
match = line.match /(.*)\\documentclass/ # no lookbehind in js regexp :(
|
||||
isRootDoc = Path.extname(path).match(/\.R?tex$/) and match and !match[1].match /%/
|
||||
# We've had problems with this regex locking up CPU.
|
||||
# Previously /.*\\documentclass/ would totally lock up on lines of 500kb (data text files :()
|
||||
# This regex will only look from the start of the line, including whitespace so will return quickly
|
||||
# regardless of line length.
|
||||
match = line.match /^\s*\\documentclass/
|
||||
isRootDoc = Path.extname(path).match(/\.R?tex$/) and match
|
||||
if isRootDoc
|
||||
rootDocId = doc?._id
|
||||
cb(rootDocId)
|
||||
|
|
Loading…
Reference in a new issue