pgcli icon indicating copy to clipboard operation
pgcli copied to clipboard

The \e feature to jump to an editor does not work with gvim. (graphical vim)

Open bossstein opened this issue 3 years ago • 2 comments

Description

The \e feature to jump to an editor does not work with gvim. When I use it with other editors the text you have written so far goes into the editor and you can edit then after a save and quit you get that same text back in pgcli. With gvim the editor always opens empty and after save and quit nothing is returned to pgcli.

It selects gvim because that is what I have selected under $VISUAL environment variable. I would be even more happy to use vim in terminal, which does work under the $EDITOR environment variable but it only defaults to this if $VISUAL is empty. There is no option to chose an alternate editor as far as I can see.

As such I think there are some sub-tasks here:

  1. Fix gvim compatibility.
  2. Add config option to use the non-visual editor option.
  3. And/Or add config option to set alternate editor.
  4. The docs on the website are inconsistent. Someplace says only $EDITOR is used which is incorrect.

I am happy to take a punt at this issue myself but I may not have time this week in which case it will be three weeks at the earliest.

Your environment

Ubuntu 20.04.4 LTS pgcli version 3.4.1 vim version 8.1.3741

pip-freeze.txt

bossstein avatar May 24 '22 16:05 bossstein

I found that my issue was that gvim forks when it's run from the terminal. There is an option to run --nofork . This isn't ideal but I can, as a work around, set my VISUAL variable to gvim --nofork.

I found that the functionality here uses the pgspecial library that in turn uses the click library. The click library supports specifying an editor. I have therefore made a tiny pull request to the pgspecial library to expose that feature.

Once the pgspecial library supports this I have the change ready to add a config option for a non default editor to pgcli.

bossstein avatar Jun 12 '22 08:06 bossstein

@bossstein I approved your PR to pgspecial and will merge it when you add the change to the changelog.

j-bennet avatar Jun 17 '22 17:06 j-bennet