Skip to content

Commit

Permalink
Merge pull request #61 from Focus/revert-60-master
Browse files Browse the repository at this point in the history
Revert "Enable \ref from any subfolders just like \cite"
  • Loading branch information
Focus authored Sep 21, 2017
2 parents c25aec3 + 37b48f0 commit 1f08eeb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 88 deletions.
20 changes: 12 additions & 8 deletions lib/label-view.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{$,SelectListView} = require 'atom-space-pen-views'
FindLabels = require './find-labels'
ListLabels = require './list-labels'
fs = require 'fs-plus'
pathModule = require 'path'

module.exports =
class LabelView extends SelectListView
Expand All @@ -18,12 +16,18 @@ class LabelView extends SelectListView
@editor = editor
file = editor?.buffer?.file
basePath = file?.path
activePaneItemPath = basePath
texRootRex = /%(\s+)?!TEX root(\s+)?=(\s+)?(.+)/g
texRootRex = /%!TEX root = (.+)/g
while(match = texRootRex.exec(@editor.getText()))
absolutFilePath = FindLabels.getAbsolutePath(activePaneItemPath,match[4])
basePath = pathModule.dirname(absolutFilePath)
labels = ListLabels.fromDir(basePath, /\.tex$/);
absolutFilePath = FindLabels.getAbsolutePath(basePath,match[1])
try
text = fs.readFileSync(absolutFilePath).toString()
labels = FindLabels.getLabelsByText(text, absolutFilePath)
catch error
errmsg = 'could not load content of #{absolutFilePath}'
atom.notifications.addError(errmsg, { dismissable: true })
console.log(error)
if labels == undefined or labels.length == 0
labels = FindLabels.getLabelsByText(@editor.getText(), basePath)
@setItems(labels)
@panel ?= atom.workspace.addModalPanel(item: this)
@panel.show()
Expand All @@ -40,7 +44,7 @@ class LabelView extends SelectListView
"label"

viewForItem: ({label}) ->
"<li>#{label}</li>"
"<li>#{label}</li>"

confirmed: ({label}) ->
@editor.insertText label
Expand Down
80 changes: 0 additions & 80 deletions lib/list-labels.js

This file was deleted.

0 comments on commit 1f08eeb

Please sign in to comment.