jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
30.43k stars 1.58k forks source link

Color of 'vim' not working after running 'jq' #1287

Open BubbaBlaster opened 7 years ago

BubbaBlaster commented 7 years ago

After running jq, when editing a file in 'vim' the color is the same as the background. This happens even if I suppress color output.

nicowilliams commented 7 years ago

Instructions to reproduce this? I use jq and vim and I've never seen this. What terminal emulator are you using?

olesteban commented 5 years ago

It's happening also to me (sort of). I normally use TCC, but also happens with Win8's cmd. After running jq and then vim, this is what I see: imagen

jq is at 1.5, vim at 8.1 (8.0 failed the same).

nicowilliams commented 5 years ago

@BubbaBlaster Were you using Windows, like @olesteban?

nicowilliams commented 5 years ago

I don't see this on Linux. I'll have to see on Windows. I'd appreciate some help on the Windows side of things, which might be caused by:

    239 int main(int argc, char* argv[]) {
    240   jq_state *jq = NULL;
    241   int ret = 0;
    242   int compiled = 0;
    243   int parser_flags = 0;
    244   int nfiles = 0;
    245   int badwrite;
    246   jv ARGS = jv_array(); /* positional arguments */
    247   jv program_arguments = jv_object(); /* named arguments */
    248
    249 #ifdef WIN32
    250   fflush(stdout);
    251   fflush(stderr);
--->252   _setmode(fileno(stdout), _O_TEXT | _O_U8TEXT);
--->253   _setmode(fileno(stderr), _O_TEXT | _O_U8TEXT);

I'm guessing we save and restore the previous mode (which _setmode() does return) for stdout and stderr.

BubbaBlaster commented 5 years ago

Yes. Windows.