Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix temporary files recognition #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix temporary files recognition #73

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 17, 2016

This commit fixes an issue connected with temporary files recognition
during auto-completion process. Invoking the “find definition” facility
on a symbol placed in the file currently being edited implied opening
a temporary file (with a .racertmp infix), which does not seem to exist
at the moment immediately after executing a Racer command.

The RacerClient class imports temp and performs a temp.open() call
for creating, opening and writing a temporary file passed into Racer.
The temp library uses Math.random and toString(36) in order to
produce a random path suffix. When called on a floating-point number,
the toString method generate a string containing a decimal delimeter
(.). Hence that random path suffix contains an extra dot
(e.g. ._main.rs.racertmp116717-2079-43y0eh.hktltbj4i), and extname
yields some random noise (.hktltbj4i in the previous example) instead
of a string starting with .racertmp. That was not correctly handled
by the code.

The attached screenshot illustrates what happened on my machine
before applying the patch.
A screenshot of at Atom session depicting the issue

This commit fixes an issue connected with temporary files recognition
during auto-completion process. Invoking the “find definition” facility
on a symbol placed in the file currently being edited implied opening
a temporary file (with a `.racertmp` infix), which does not seem to exist
at the moment immediately after executing a Racer command.

The RacerClient class imports `temp` and performs a `temp.open()` call
for creating, opening and writing a temporary file passed into Racer.
The `temp` library uses `Math.random` and `toString(36)` in order to
produce a random path suffix. When called on a floating-point number,
the `toString` method generate a string containing a decimal delimeter
(`.`). Hence that random path suffix contains an extra dot
(e.g. `._main.rs.racertmp116717-2079-43y0eh.hktltbj4i`), and `extname`
yields some random noise (`.hktltbj4i` in the previous example) instead
of a string starting with `.racertmp`. That was not correctly handled
by the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants