Pass correct path to synctex when not in root folder

This commit is contained in:
James Allen 2014-05-29 16:41:24 +01:00
parent e1a547c202
commit 073b52e693
2 changed files with 12 additions and 0 deletions

View file

@ -121,6 +121,7 @@ define [
lastPart = parts.pop()
getChildWithName = (folder, name) ->
return folder if name == "."
foundChild = null
for child in folder.get("children").models
if child.get("name") == name
@ -145,6 +146,10 @@ define [
path = entity.get("name") + "/" + path
return path
getRootFolderPath: () ->
rootFilePath = @getPathOfEntityId(@project.get("rootDoc_id"))
return rootFilePath.split("/").slice(0, -1).join("/")
getNameOfEntityId: (entity_id) ->
entity = @getEntity(entity_id)
return if !entity?

View file

@ -280,6 +280,13 @@ define [
syncToPdf: () ->
entity_id = @ide.editor.getCurrentDocId()
file = @ide.fileTreeManager.getPathOfEntityId(entity_id)
# If the root file is folder/main.tex, then synctex sees the
# path as folder/./main.tex
rootFolderPath = @ide.fileTreeManager.getRootFolderPath()
if rootFolderPath != ""
file = file.replace(RegExp("^#{rootFolderPath}"), "#{rootFolderPath}/.")
line = @ide.editor.getCurrentLine()
column = @ide.editor.getCurrentColumn()