tern_for_sublime icon indicating copy to clipboard operation
tern_for_sublime copied to clipboard

Inconsistent info in tooltips

Open zaynv opened this issue 8 years ago • 4 comments

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 avatar Jul 02 '16 17:07 zaynv

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?

zaynv avatar Jul 02 '16 21:07 zaynv

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

marijnh avatar Jul 04 '16 15:07 marijnh

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

zaynv avatar Jul 04 '16 21:07 zaynv

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.

marijnh avatar Aug 16 '16 14:08 marijnh