tpope / vim-projectionist

projectionist.vim: Granular project configuration
https://www.vim.org/scripts/script.php?script_id=4989
1.06k stars 67 forks source link

json_parse appears broken under latest vim #152

Closed fourjay closed 4 years ago

fourjay commented 4 years ago

I pulled and compiled the latest vim and something there appears to have broken projectionist#json_parse() It started throwing the error "invalid JSON: " on a long stable* bit of json. I reverted to vim hash 209f0208f7831c6ab8f3f1cab473cb21e7985fc3 And the problem goes away.

Here is the json that's being rejected. (FWIW, I keep a largish global projection, easier to maintain as JSON than as vimscript)

{
    ".git/|Makefile|*.php|*.pl|*.sh": {
        "*.php": {
            "template": [
                "<?php"
            ]
        },
        "*.pl": {
            "template": [
                "#!/usr/bin/env perl",
                "use strict;",
                "use warnings;"
            ]
        },
        "*sh": {
            "template": [
                "skel"
            ]
        },
        ".ctagsignore": {
            "type": "ctagsignore"
        },
        ".gitignore": {
            "template": [
                "skel"
            ],
            "type": "gitignore"
        },
        ".projections.json": {
            "template": [
                "skel"
            ],
            "type": "projections"
        },
       "Makefile": {
            "template": [
                "skel"
            ],
            "type": "makefile"
        }
    }
}
fourjay commented 4 years ago

Adding a conditional branch to projection#json_parse fixes this

67 function! projectionist#json_parse(string) abort
68   if exists('*json_decode')
69       return json_decode(join(a:string))
70   endif

Seems a reasonable addition addition anyways. I'm guessing the try isn't needed since the eval is gone.