Commit Graph

4144 Commits

Author SHA1 Message Date
ZyX
c9963872ef shada: Always use merging when reading jumps and changes 2015-10-08 22:00:36 +03:00
ZyX
4371842bcc shada: Call regtilde when reading last replacement string 2015-10-08 22:00:36 +03:00
ZyX
830c8bd23e functests: Add a number of “generic” functional tests 2015-10-08 22:00:36 +03:00
ZyX
c5554cbb87 shada: Use hash for searching for history entries 2015-10-08 22:00:35 +03:00
ZyX
bcdda63e3a shada: Allocate all hashes on stack 2015-10-08 22:00:35 +03:00
ZyX
fd4d5521a3 shada,functests: Use special sd_reader function for skipping 2015-10-08 22:00:34 +03:00
ZyX
17b5d27d85 functests: Move wshada and sdrcmd commands to helpers 2015-10-08 22:00:34 +03:00
ZyX
42fbfd3aee shada: Add warning about removing/renaming temporary file 2015-10-08 22:00:30 +03:00
ZyX
1542fc221e shada,functests: Improve detection of invalid ShaDa files
It appears that large portion of non-ShaDa ASCII text files may be parsed as
a ShaDa file because it is mostly recognized as a sequence of unknown entries:
all ASCII non-control characters are recognized as FIXUINT shada objects, so
text like

    #!/bin/sh

    powerline "$@" 2>&1 | tee -a powerline

(with trailing newline) will be recognized as a correct ShaDa file containing
single unknown entry with type 0x23 (dec 35, '#'), timestamp 0x21 (dec 33, '!')
and length 0x2F (dec 47, '/') without this commit. With it parsing this entry
will fail.
2015-10-08 22:00:29 +03:00
ZyX
1e06792099 scripts: Improve shadacat to work with unknown items 2015-10-08 22:00:29 +03:00
ZyX
d8b0cd5c17 documentation: Add extended ShaDa format description 2015-10-08 22:00:28 +03:00
ZyX
aea7f6aa72 ex_getln: Refactor HIST_\* list of macros to enum 2015-10-08 22:00:27 +03:00
ZyX
fce9590cfc shada: When packing header, pack mapping keys as strings, not binary 2015-10-08 22:00:25 +03:00
ZyX
12a31c70c1 shada,functests: Test compatibility support
For compatibility the following things are done:

1. Items with type greater then greatest type are ignored when reading and
   copied when writing.
2. Registers with unknown name are ignored when reading and blindly copied when
   writing.
3. Registers with unknown type are ignored when reading and merged as usual when
   writing.
4. Local and global marks with unknown names are ignored when reading. When
   writing global marks are blindly copied and local marks are also blindly
   copied, but only if file they are attached to fits in the `'N` limit defined
   in &shada. Unknown local mark’s timestamp is also taken into account when
   calculating which files exactly should fit into this limit.
5. History items with unknown type are ignored when reading and blindly copied
   when writing.
6. Unknown keys found in register, local marks, global marks, changes, jumps and
   search pattern entries are read to additional_data Dictionary and dumped (of
   course, unless any of these elements were not overwritten later). It
   obviously works only for values conversible to Object type.
7. Additional elements found in replacement string and history entries are read
   to additional_elements Array and dumped (same: only if they were not
   overwritten later). Again this works only for elements conversible to Object
   type.
8. Additional elements found in variable entries are simply ignored when
   reading. When writing *new* variables they will be preserved during merging,
   but that’s all. Variable values dumped from current NeoVim session never have
   additional elements.
2015-10-08 22:00:25 +03:00
ZyX
82934e8797 shada: Fix GCC -Wconversion warnings in srni_flags definitions 2015-10-08 22:00:25 +03:00
ZyX
278de872f7 shada: Synchronize sd_writer file before closing 2015-10-08 22:00:24 +03:00
ZyX
21056bad57 documentation: Describe forward compatibility limitations 2015-10-08 22:00:24 +03:00
ZyX
2244db67aa shada: Do not allow empty keys 2015-10-08 22:00:22 +03:00
ZyX
5b3e668f3e shada: When reading marks or registers, free items when set fails 2015-10-08 22:00:17 +03:00
ZyX
07d9ab26c6 *: Make ShaDa code use VimL values for additional_\* data 2015-10-08 22:00:16 +03:00
ZyX
56174572bc shada,documentation: Extend read error handling, handle write errors
Modifications:
- If file was not written due to write error then writing stops and temporary
  file will not be renamed.
- If NeoVim detects that target file is not a ShaDa file then temporary file
  will not be renamed.
2015-10-08 22:00:16 +03:00
ZyX
f8169ff24d documentation: Document ShaDa compatibility features 2015-10-08 22:00:16 +03:00
ZyX
38b8eb3561 scripts: Also print entry offset in shadacat.py 2015-10-08 22:00:16 +03:00
ZyX
e2994a3c62 shada,functests: Test how ShaDa support code reacts on errors
Some notes:
- Replaced msgpack_unpacker usage with regular xmalloc’ed buffer. Also since
  msgpack_unpack_next (as well as msgpack_unpacker_next) is not ever going to
  return MSGPACK_UNPACK_EXTRA_BYTES this condition was checked manually.
  Function that does return this status is msgpack_unpack, but it is marked as
  obsolete.
- Zero type is checked prior to main switch in shada_read_next_item because
  otherwise check would be skipped.
- Zeroing entry at the start of shada_read_next_item makes it safer.
- dedent('') does not work.
- v:oldfiles list is only replaced with bang, if it is NULL or empty.
2015-10-08 22:00:15 +03:00
ZyX
b7ca976f73 shada: Make all mapping keys have at most 2 byte length
Now all keys are defined in a way that makes it easy to redefine if needed.
2015-10-08 22:00:15 +03:00
ZyX
21c12cf4e7 shada: Do not handle EINTR in open_file
It is already handled by libuv which is used by os_open.
2015-10-08 22:00:15 +03:00
ZyX
931539d108 shada: Do not export shada_read_file
Unlike some wrapper functions it is not used actually, so no need to export it.
Also removed ShadaPosition typedef which was not used.
2015-10-08 22:00:14 +03:00
ZyX
8dafa533db shada: Translate errors and add error codes
Notes:
- E136 code greatly changed its meaning: now it is write error and not read
  error.
- E195 was removed because shada_read_everything will already do all the
  necessary error reporting.
- E886 can be reported by both :rshada and :wshada, but :rshada comes first and
  AFAIR it is the only error which is not E575 and can be reported by :rshada.
2015-10-08 22:00:14 +03:00
ZyX
fa8e3f3f20 shada: Only check errno if read/write returned -1
According to the manual (POSIX) this is the only case when errno is set by these
functions. This is needed because some functions (e.g. buflist_new) leave errno
set to non-zero value under some conditions (e.g. when opening non-existing
files).
2015-10-08 22:00:14 +03:00
ZyX
40bbaa757e shada: Put pointer to the close function into reader/writer structure 2015-10-08 22:00:13 +03:00
ZyX
ebf3c86a55 shada: Handle all possible msgpack_unpacker_next returns 2015-10-08 22:00:13 +03:00
ZyX
83785ef98b viminfo: Remove old code 2015-10-08 22:00:13 +03:00
ZyX
43fe98c9fb shada: Add support for merging everything like described in the doc 2015-10-08 22:00:13 +03:00
ZyX
4bc053facd shada: Do not copy history entries when writing 2015-10-08 22:00:12 +03:00
ZyX
5e7a7fc2da documentation: Document how ShaDa entries should be merged 2015-10-08 22:00:12 +03:00
ZyX
f10960869f shada: Do not save search pattern/sub string when it is older 2015-10-08 22:00:12 +03:00
ZyX
9d2615df86 shada: Use os_strerror in place of strerror in some places 2015-10-08 22:00:11 +03:00
ZyX
09cbec6476 shada: Use os_mkdir_recurse to create directory for ShaDa file 2015-10-08 22:00:11 +03:00
ZyX
0018b4f579 shada: Refactor history merger to use statically sized 2linked list
Also fixes the error: when writing shada files existing history items may be
freed.

Warning: valgrind reports some memory leaks.
2015-10-08 22:00:10 +03:00
ZyX
875d287d4b functests: Test that history is still accessible after :wshada 2015-10-08 22:00:10 +03:00
ZyX
6f6497f5e0 shada: Refactor history merging support to separate functions 2015-10-08 22:00:10 +03:00
ZyX
b905c8a942 shada: Preserve existing file permissions 2015-10-08 22:00:09 +03:00
ZyX
1d3823a5c9 shada: Populate v:oldfiles 2015-10-08 22:00:09 +03:00
ZyX
f43a5e6926 shada: Save v:hlsearch value 2015-10-08 22:00:08 +03:00
ZyX
7abe20f3d3 main: Silence -Wunused-result in main.c for shada_read_file 2015-10-08 22:00:07 +03:00
ZyX
45ad810341 shada: Add more size_t casts
As usual, GCC is overparanoid with -Wconversion.
2015-10-08 22:00:07 +03:00
ZyX
8663983cc4 Deprecate &viminfo and :[rw]v, add &shada and :[rw]sh 2015-10-08 22:00:07 +03:00
ZyX
9cf9c4a586 Replace references to viminfo in various places 2015-10-08 22:00:06 +03:00
ZyX
749cae8662 functests: Fix change list ShaDa test failures 2015-10-08 22:00:06 +03:00
ZyX
602efe856a shada: Use “write then rename” variant by default for writing shada 2015-10-08 22:00:05 +03:00