Skip to content
This repository was archived by the owner on Jan 3, 2019. It is now read-only.

Tooltips only show at the last character active patterns #217

Closed
7sharp9 opened this issue Oct 6, 2013 · 10 comments · Fixed by #265
Closed

Tooltips only show at the last character active patterns #217

7sharp9 opened this issue Oct 6, 2013 · 10 comments · Fixed by #265

Comments

@7sharp9
Copy link
Member

7sharp9 commented Oct 6, 2013

The following code only shows a tooltip at the § indicated:

  let (|MemberName§|_|) (name:string) = 
      let dotRight = name.LastIndexOf '.'
      if dotRight < 1 || dotRight >= name.Length - 1 then None else
      let typeName = name.[0..dotRight-1]
      let elemName = name.[dotRight+1..]
      Some (typeName,elemName)
@7sharp9
Copy link
Member Author

7sharp9 commented Dec 19, 2013

@rneatherway Is this the same issue as tooltips where you have to advance to the end of the ident, looks like it, maybe this is a fringe parser case?

@rneatherway
Copy link
Contributor

I just tried it and on my system I don't get a tooltip at any point in MemberName. I did notice that if I hover at the point you indicate then the parsing now picks up MemberName| (including the pipe) because it accepts a symbol fragment forward. If anything that says to me that it shouldn't work in that position but it should earlier in the ident.

For all positions I get DataTipText []

@7sharp9
Copy link
Member Author

7sharp9 commented Dec 19, 2013

Actually now it only works at:

let (|MemberName|_§|) (name:string) =
and
let (|MemberName|_|§) (name:string) =

I guess fast forwarding to the ident to the last position of the ident is whats going to fix it.

@rneatherway
Copy link
Contributor

This seems to do the trick: https://github.com/rneatherway/fsharpbinding/tree/issue217

Let me know what you think, it passes the regression suite on fsautocomplete.

(And works in Monodevelop!)

@rneatherway
Copy link
Contributor

New version just pushed, hopefully fixes it. It doesn't quite work on my monodevelop but I think this is because it's out of date.

@rneatherway
Copy link
Contributor

And again, I updated monodevelop and it works for me now.

@7sharp9
Copy link
Member Author

7sharp9 commented Dec 19, 2013

Didn't make any difference for me. Also it doesn't work for this position

let (|Zero§|Succ|) n = if n = 0 then Zero else Succ(n-1)

It does work for: let (|Zero|Succ|§) n = if n = 0 then Zero else Succ(n-1)
but not this one: let (§|Zero|Succ|) n = if n = 0 then Zero else Succ(n-1)

It think it should logically work for every character between the banana clips like this:
let (|§Zero|Succ§|) n = if n = 0 then Zero else Succ(n-1)

@rneatherway
Copy link
Contributor

Did you try the latest commit? Those examples all work for me. Making it not work outside the banana clips might be difficult because the standard ident parser allows the empty string, and this is what is causing is to succeed in the case of:

let (|Zero|Succ|§) n = if n = 0 then Zero else Succ(n-1)

@7sharp9
Copy link
Member Author

7sharp9 commented Dec 19, 2013

The last one worked, I think this is fine then, it was more about the left and right hand side being consistent.

I think the tooltips have improved a great deal with all the work thats been done on them of late! :-)

@rneatherway
Copy link
Contributor

Ah good, yes I think things are coming along very nicely!

I actually agree with you about the hover location, as in I think this is best:

let (|§Zero|Succ§|) n = if n = 0 then Zero else Succ(n-1)

And I can make idents be required to have length at least 1 without breaking anything, but then it isn't possible to distinguish between the first pipe and subsequent pipes inside the active pattern. So I can't prevent:

let (§|Zero|Succ|) n = if n = 0 then Zero else Succ(n-1)

without also preventing:

let (|Zero§|Succ|) n = if n = 0 then Zero else Succ(n-1)

which was the previous situation.

I think people will be unlikely to notice these little quibbles hopefully! I'll merge it in then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants