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

[Emacs] Completion of identifiers containing spaces #233

Closed
ghost opened this issue Oct 31, 2013 · 10 comments
Closed

[Emacs] Completion of identifiers containing spaces #233

ghost opened this issue Oct 31, 2013 · 10 comments

Comments

@ghost
Copy link

ghost commented Oct 31, 2013

In the emacs mode, if a completion choice contains a space, the inserted text should have double-ticks around it, e.g.

 #r "../../bin/FSharp.Data.dll"
 let data = FSharp.Data.FreebaseData.GetDataContext()

 data.Arts and Entertainment   //  This should be given double-ticks
@ghost ghost assigned rneatherway Oct 31, 2013
@rneatherway
Copy link
Contributor

Thanks for reporting it. I'm working on a new release including performance improvements. I'll roll a fix for this into it.

@ghost
Copy link
Author

ghost commented Oct 31, 2013

Another thing in the same line - completion should be adjusted to work in these situations (the second more important than the first):

data.``Arts and Ente(*M-TAB-REQUEST-COMPLETION-HERE*)

data.``Arts and Entertainment``(*PRESS-DOT-HERE*)

This is not that easy because the F# language service requires the "name" cracking to be done by the hosting editor. There is code in the monodevelop binding that takes double-ticks into account when cracking the text for the name when parsing backwards here: https://github.com/fsharp/fsharpbinding/blob/master/monodevelop/MonoDevelop.FSharpBinding/Services/LanguageService.fs#L370

I think nearly everything in that file should be put into FSharp.Compiler.Editor.dll, fsautocomplete.exe or some other shared component so that this doesn't have to be re-implemented by every editor (including the code to crack the help text for Mono)

@rneatherway
Copy link
Contributor

In both cases it should insert the missing backticks? Is this while a
completion session is open?

I agree it would be great if we could just request completions at a
particular location and have all the name cracking edge cases handled in a
single place.

On Thu, Oct 31, 2013 at 12:02 PM, Don Syme notifications@github.com wrote:

Another thing in the same line - completion should be adjusted to work in
these situations (the second more important than the first):

data.``Arts and Ente(PRESS-DOT-HERE)

data.Arts and Entertainment(PRESS-DOT-HERE)

This is not that easy because the F# language service requires the "name"
cracking to be done by the hosting editor. There is code in the monodevelop
binding that takes double-ticks into account when cracking the text for the
name when parsing backwards here:
https://github.com/fsharp/fsharpbinding/blob/master/monodevelop/MonoDevelop.FSharpBinding/Services/LanguageService.fs#L370

I think nearly everything in that file should be put into
FSharp.Compiler.Editor.dll, fsautocomplete.exe or some other shared
component so that this doesn't have to be re-implemented by every editor
(including the code to crack the help text for Mono)


Reply to this email directly or view it on GitHubhttps://github.com//issues/233#issuecomment-27480240
.

@7sharp9
Copy link
Member

7sharp9 commented Oct 31, 2013

I agree, I only there was time to do the work.

On 31 Oct 2013, at 12:07, Robin Neatherway notifications@github.com wrote:

In both cases it should insert the missing backticks? Is this while a
completion session is open?

I agree it would be great if we could just request completions at a
particular location and have all the name cracking edge cases handled in a
single place.

On Thu, Oct 31, 2013 at 12:02 PM, Don Syme notifications@github.com wrote:

Another thing in the same line - completion should be adjusted to work in
these situations (the second more important than the first):

data.``Arts and Ente(PRESS-DOT-HERE)

data.Arts and Entertainment(PRESS-DOT-HERE)

This is not that easy because the F# language service requires the "name"
cracking to be done by the hosting editor. There is code in the monodevelop
binding that takes double-ticks into account when cracking the text for the
name when parsing backwards here:
https://github.com/fsharp/fsharpbinding/blob/master/monodevelop/MonoDevelop.FSharpBinding/Services/LanguageService.fs#L370

I think nearly everything in that file should be put into
FSharp.Compiler.Editor.dll, fsautocomplete.exe or some other shared
component so that this doesn't have to be re-implemented by every editor
(including the code to crack the help text for Mono)


Reply to this email directly or view it on GitHubhttps://github.com//issues/233#issuecomment-27480240
.


Reply to this email directly or view it on GitHub.

@rneatherway
Copy link
Contributor

Hmm, the github email mangled the code block so I misunderstood.

I see the point now, but I came across a strange situation trying to build a test case:

module X =
  let ``bla bla`` = 3

  let hello = 4

X.$

Complete at $ and you get hello, but not bla bla in the list of completions. This occurs in VS, XS and Emacs.

@rneatherway
Copy link
Contributor

OK @dsyme , this is partially fixed in my current development branch at https://github.com/rneatherway/fsharpbinding/tree/async-helptext

If you have time to test that would be great

I haven't fixed:

data.``Arts and Ente(*M-TAB-REQUEST-COMPLETION-HERE*)

As I think this requires emacs to know too much. I think the better approach is to move the abstraction further into FSharp.AutoComplete. At the moment the request has to be made at the point just after the '.', but I will move this parsing into FSharp.AutoComplete and do the backwards symbol parsing there using the Monodevelop binding code.

@rneatherway
Copy link
Contributor

Update: I was wrong about the point at which the request has to be made -- FSharp.AutoComplete already expects the sensible place. However, Emacs still has to do the same parsing so that it can know where to start the completion from (i.e. the previous '.', or start of symbol if no '.'). So some logic will have to be duplicated in the emacs code.

@rneatherway
Copy link
Contributor

Hi Don, the code you linked to doesn't actually work in the case of:

``Arts and Ent$

because it only searches backwards for fsharpIdentCharacter. I think what we need here is a pattern ORed with the existing one that matches on any character as long as it finds a double backtick.

@rneatherway
Copy link
Contributor

I've also tested this in Visual Studio now and although it gets the list of completions correct, it doesn't perform the replacement correctly. You end up with:

data.``Arts and ``Arts and Entertainment``

I'm going to defer fixing this corner case until after releasing the current Emacs improvements. To fix in MD as well, the best approach is to merge the identifier cracking code into FSharp.CompilerBinding and improve a single copy.

@rneatherway
Copy link
Contributor

Fixed by #259

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

No branches or pull requests

2 participants