ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

Inconsistent info in tooltips #126

Open zaynv opened 8 years ago

zaynv commented 8 years ago

For the same code, I keep getting different stuff in my tooltip hints:

1.

screen shot 2016-07-02 at 9 45 17 am

2.

screen shot 2016-07-02 at 9 12 16 am

3.

screen shot 2016-07-02 at 9 15 41 am

I would prefer for it to always be 3, but most of the time I get the result from image 2. Is there anything I can do to make it so that it is always like image 3?

Here are my Tern user settings:

{
  "tern_argument_hints": true,
  "tern_output_style": "tooltip",
  "tern_argument_completion": true
}

Thanks in advance!

zaynv commented 8 years ago

This seems to actually happen if you close the editor. If you create the sum function during the current session and write the comments like so:

sum.js

/**
 * Returns the sum of two numbers
 * @param  {Number} a The first operand
 * @param  {Number} b The second operand
 * @return {Number}   The sum of both operands
 */
function sum (a, b) {
  return a + b
}

module.exports = sum

and then i go into app.js and do the following:

const sum = require('./sum')

sum(

I get the correct tooltip:

screen shot 2016-07-02 at 2 54 32 pm

However, if I restart the editor and try to type sum( again, I get a different output:

screen shot 2016-07-02 at 9 37 56 am

Is there any way around this?

marijnh commented 8 years ago

Could you provide me with the relevant part of your math.js file, so that I can see if I can reproduce this?

zaynv commented 8 years ago

Ah sorry, it was actually the same thing as sum.js I just named it differently that time.

Steps to reproduce:

1. Create an app.js and sum.js and open them in Sublime 2. Add the following to sum.js:

/**
 * Returns the sum of two operands
 * @param  {Number} a The first operand
 * @param  {Number} b The second operand
 * @return {Number}   The sum of both operands
 */
function sum (a, b) {
  return a + b
}

3. Add the following to app.js:

const sum = require('./sum')

sum(

At this point, everything works fine:

screen shot 2016-07-04 at 2 44 04 pm

Now, if you exit out of Sublime and reopen it, and then try doing sum( again, you will get this output instead:

screen shot 2016-07-04 at 2 46 27 pm
marijnh commented 7 years ago

I didn't manage to reproduce this. If I add the module.exports = sum line to the content you describe, I get working argument hints.