pursuit icon indicating copy to clipboard operation
pursuit copied to clipboard

Add button "copy import statement to clipboard"

Open flip111 opened this issue 4 years ago • 7 comments

Would be nice to have a small button next to functions (and other things) to format an import statement and copy it to the clipboard

flip111 avatar Jul 22 '21 17:07 flip111

Could be added here in the code https://github.com/purescript/pursuit/blob/3209916030e5bae48d4e77e7ee1e6ee833192a1b/src/Handler/Search.hs#L319

flip111 avatar Jan 22 '23 17:01 flip111

I kind of find it hard to justify this because I feel like this is a very rare use case. Put differently, is this just going to clutter up the UI if we add a button like this?

JordanMartinez avatar Jan 31 '23 15:01 JordanMartinez

Screenshot from 2023-01-31 23-08-04

Something like this, but better designed button. Probably could go on the module page too (screenshot is from search). Button could also be placed top-right similar to where Source is located next to functions in module docs.

I think the use case of looking up docs and then typing module name and function name into your code is very frequent. Now i usually scroll to top of page, copy the module name. And then i do this import <CTRL + V> (<function name i remembered>).

@JordanMartinez how does your workflow look like?

flip111 avatar Jan 31 '23 22:01 flip111

:facepalm: I literally thought this issue was on the Try PureScript repo...

Ok. The copy import button does make sense.

JordanMartinez avatar Feb 02 '23 00:02 JordanMartinez

What are your thoughts on making the proposed button also copy it as a qualified import that the user defines? So,

  1. user interacts with the button (e.g. Ctrl+Click to trigger this behavior)
  2. an input appears and is focused
  3. user types in some alias (e.g. "Functor") and types Enter
  4. the following is copied to your clipboard:
import Data.Functor as Functor

JordanMartinez avatar Feb 02 '23 00:02 JordanMartinez

Seems like a good idea to me :)

I'm thinking whether it would pay off to have a toggle (i.e. checkbox) to enable/disable the popup somewhere (toggle state stored on the browser)

flip111 avatar Feb 05 '23 17:02 flip111

:man_shrugging: I don't know, but I would focus on getting your original idea in first. Otherwise, it may never get implemented due to focusing too much on my suggestions.

JordanMartinez avatar Feb 07 '23 02:02 JordanMartinez