vim / vim

The official Vim repository
https://www.vim.org
Vim License
36.43k stars 5.44k forks source link

incorrect fold in json file #4658

Open europarl-data opened 5 years ago

europarl-data commented 5 years ago

Describe the bug My json file (https://github.com/europeelects/europarl-national-election-systems/blob/master/references_for_laws.json) is folded in a different way by vim than on http://jsonviewer.stack.hu/. My json file is an array on its top level; consisting of 8 objects (index 0 - 7). But somehow, vim does not recognise the last and second-last object in this array. Instead, vim incorrectly inserts the last (index 7) and second-last (index 6) object into the third-last object (index 5), making my array only 6 objects (index 0 - 5) long.

To Reproduce - in vim:

  1. vim --clean
  2. :edit references_for_laws.json (from https://github.com/europeelects/europarl-national-election-systems/blob/master/references_for_laws.json)
  3. :set filetype=json
  4. :syntax on
  5. :set foldmethod=syntax
  6. Go to the first line of the file and type zo => result: vim shows only 6 lines / 6 objects: vim_incorrect_fold

Expected behavior: see http://jsonviewer.stack.hu/

  1. Go to http://jsonviewer.stack.hu/
  2. Paste the file content from https://github.com/europeelects/europarl-national-election-systems/blob/master/references_for_laws.json in there
  3. Go to the tab viewer
  4. As you can see in the picture, 8 objects are listed with the indexes 0 to 7: json_array_correct

Environment

chrisbra commented 5 years ago

Please test with the latest version 396e829 (which was just uploaded). Note, according to this comment we don't have an active json syntax file maintainer currently. It would help, if someone would volunteer maintaining (hint)