vscode-ocaml-platform icon indicating copy to clipboard operation
vscode-ocaml-platform copied to clipboard

Automatic interface/mli generation should use virtual files / temporary buffers

Open ELLIOTTCABLE opened this issue 2 years ago • 3 comments

At the moment, if I need to quickly check whether a given file I'm looking at has any docs, the go-to seems to be O. This, sometimes-helpfully, generates an interface if none exists.

However, about half the time, that means one has to deal with this dialog:

Screen Shot 2022-07-05 at 2 37 15 PM

Generally speaking, I'd say that this should default to not saving the file. (My logic being this: you either slightly-annoy people trying to check-the-file-if-it-exists, to save some annoyance on behalf of someone who is trying to use VScode to generate the initial intf-file for a module that doesn't yet have one; or vice versa: annoy file-creators a little more ("wait! why didn't that save?"), at the cost of annoying file-readers a little less. I'd suppose that the former activity, reading, is much, much more common than the latter activity, creating.)

Would it be possible for the extension to, if the .mli doesn't already exist, use a virtual document for this? Or, in some other way, prevent the above blocking modal from appearing on created MLIs?

ELLIOTTCABLE avatar Jul 05 '22 19:07 ELLIOTTCABLE

I'd say that this should default to not saving the file

I don't think we can configure that, if you intended to propose a change there.

I just do cmd + delete to pick "don't save" (that's the default keybinding on mac to pick "cancel" out of two options)

I agree that the workflow could be improved though.

ulugbekna avatar Jul 05 '22 19:07 ulugbekna

if I need to quickly check whether a given file I'm looking at has any docs, the go-to seems to be ⌥O. This, sometimes-helpfully, generates an interface if none exists.

Why do we do this anyway? If the .mli doesn't exist I don't think we should automatically insert anything.

rgrinberg avatar Jul 07 '22 00:07 rgrinberg

We do that because the code action to insert the interface is not very discoverable for the user, IIRC. I don’t like this insertion too much either. I think we could distinguish switch with insertion to another keybiding shift+option+o (vs current option+o which would just do the switch)

ulugbekna avatar Jul 07 '22 07:07 ulugbekna