<div>Hi there,</div><div><br></div><div>There seems to be a bug in the LaTeX bundle's reference/citation auto-complete for my specific set-up.</div><div>I'm fairly sure I've fixed it (though its possible this is not the best / most generic method) so I'll try to describe my problem / situation:</div>

<div><br></div><div>In my project I have a master .tex document, and several other .tex files (each with something like the following line as their first line):</div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">

%!TEX root = ../thesis.tex</blockquote><div><div><br></div><div>When I attempted to auto-complete references/citations I'd get this error (output directly in my file at the cursor, not as a pop-up or tooltip):</div></div>

<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:19:in `initialize': No such file or directory - /Users/andrew/Documents/Uni/Papers/Writing/Thesis/thesis.tex<br>

 (Errno::ENOENT)<br><span class="Apple-tab-span" style="white-space:pre">       </span>from /Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:19:in `open'<br><span class="Apple-tab-span" style="white-space:pre">  </span>from /Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:19:in `options'<br>

<span class="Apple-tab-span" style="white-space:pre"> </span>from /Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:45:in `master'<br><span class="Apple-tab-span" style="white-space:pre">        </span>from /Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb:56:in `get_labels'<br>

<span class="Apple-tab-span" style="white-space:pre"> </span>from /tmp/temp_textmate.oacqrp:8<br>File:<br>/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb</blockquote><div>

<div><br></div><div>The file that it claims does not exist definitely exists, but in the error message that was output in my document, there was a diamond character immediately after "thesis.tex", visible because i have the "Show Invisibles" TextMate setting enabled.</div>

<div>I copied the text including the diamond character and pasted it into a web-based ascii-to-hex converter (<a href="http://centricle.com/tools/ascii-hex/">http://centricle.com/tools/ascii-hex/</a>) and it seems to be the character %0A, i.e. the Line Feed or new line character (\n), suggesting the script is erroneously including the \n as part of the TEX root filename property.</div>

<div>- I've checked the document in TextMate with Show Invisibles on and cannot see any extra characters</div><div>- I've also tried deleting the line and typing it out again</div><div>- I've tried using absolute and relative paths for the root document property</div>

<div>None of these solved the problem (and none had any detrimental effect after I'd fixed it as described below).</div><div><br></div><div>I've fixed the problem by editing the script:</div><div>/Applications/TextMate.app/Contents/SharedSupport/Bundles/LaTeX.tmbundle/Support/lib/LaTeXUtils.rb</div>

<div>and changing line 42 from:</div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">new_master = (master.parent + Pathname.new(opts['root'])).cleanpath</blockquote>

<div><div>to:</div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">new_master = (master.parent + Pathname.new(opts['root']<b>.strip</b>)).cleanpath</blockquote>

<div><div><div><br></div><div>This fix would probably break the functionality of the root file if the full specified path is required to start or end with a space (e.g. the root file is called "master.tex "). I don't think quotation marks are allowed here to account for this somewhat unlikely scenario, but it may well break the script for someone. Perhaps a slightly better fix would be to remove a single trailing \n character if it is present (however this is beyond my Ruby scripting abilities).</div>

<div><br></div><div>Anyway, hope this is of some help and some kind of fix can be put into the official bundle</div><div><br></div><div>cheers,</div></div>Andrew</div><div><br>
</div>