~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to src/nvim/undo.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-04-18 21:42:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20160418214219-1e6d4o1fwqarzk46
Tags: 0.1.3-1
* New upstream release.  (Closes: #820562)
* debian/control:
  + Remove unnecessary luarocks Build-Depends
  + Add libkvm-dev Build-Depends for kfreebsd-*
  + Add python(3)-neovim to Recommends.  (Closes: #812737)
  + Declare compiance with policy 3.9.8, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * The saved lines are stored in a list of lists (one for each buffer):
5
5
 *
6
6
 * b_u_oldhead------------------------------------------------+
7
 
 *                                                            |
8
 
 *                                                            V
9
 
 *                +--------------+    +--------------+    +--------------+
10
 
 * b_u_newhead--->| u_header     |    | u_header     |    | u_header     |
11
 
 *                |     uh_next------>|     uh_next------>|     uh_next---->NULL
12
 
 *         NULL<--------uh_prev  |<---------uh_prev  |<---------uh_prev  |
13
 
 *                |     uh_entry |    |     uh_entry |    |     uh_entry |
14
 
 *                +--------|-----+    +--------|-----+    +--------|-----+
15
 
 *                         |                   |                   |
16
 
 *                         V                   V                   V
17
 
 *                +--------------+    +--------------+    +--------------+
18
 
 *                | u_entry      |    | u_entry      |    | u_entry      |
19
 
 *                |     ue_next  |    |     ue_next  |    |     ue_next  |
20
 
 *                +--------|-----+    +--------|-----+    +--------|-----+
21
 
 *                         |                   |                   |
22
 
 *                         V                   V                   V
23
 
 *                +--------------+            NULL                NULL
24
 
 *                | u_entry      |
25
 
 *                |     ue_next  |
26
 
 *                +--------|-----+
27
 
 *                         |
28
 
 *                         V
29
 
 *                        etc.
 
7
 *                                                            |
 
8
 *                                                            V
 
9
 *                +--------------+    +--------------+    +--------------+
 
10
 * b_u_newhead--->| u_header     |    | u_header     |    | u_header     |
 
11
 *                |     uh_next------>|     uh_next------>|     uh_next---->NULL
 
12
 *         NULL<--------uh_prev  |<---------uh_prev  |<---------uh_prev  |
 
13
 *                |     uh_entry |    |     uh_entry |    |     uh_entry |
 
14
 *                +--------|-----+    +--------|-----+    +--------|-----+
 
15
 *                         |                   |                   |
 
16
 *                         V                   V                   V
 
17
 *                +--------------+    +--------------+    +--------------+
 
18
 *                | u_entry      |    | u_entry      |    | u_entry      |
 
19
 *                |     ue_next  |    |     ue_next  |    |     ue_next  |
 
20
 *                +--------|-----+    +--------|-----+    +--------|-----+
 
21
 *                         |                   |                   |
 
22
 *                         V                   V                   V
 
23
 *                +--------------+            NULL                NULL
 
24
 *                | u_entry      |
 
25
 *                |     ue_next  |
 
26
 *                +--------|-----+
 
27
 *                         |
 
28
 *                         V
 
29
 *                        etc.
30
30
 *
31
31
 * Each u_entry list contains the information for one undo or redo.
32
32
 * curbuf->b_u_curhead points to the header of the last undo (the next redo),
37
37
 * uh_seq field is numbered sequentially to be able to find a newer or older
38
38
 * branch.
39
39
 *
40
 
 *                 +---------------+    +---------------+
41
 
 * b_u_oldhead --->| u_header      |    | u_header      |
42
 
 *                 |   uh_alt_next ---->|   uh_alt_next ----> NULL
43
 
 *         NULL <----- uh_alt_prev |<------ uh_alt_prev |
44
 
 *                 |   uh_prev     |    |   uh_prev     |
45
 
 *                 +-----|---------+    +-----|---------+
46
 
 *                       |                    |
47
 
 *                       V                    V
48
 
 *                 +---------------+    +---------------+
49
 
 *                 | u_header      |    | u_header      |
50
 
 *                 |   uh_alt_next |    |   uh_alt_next |
51
 
 * b_u_newhead --->|   uh_alt_prev |    |   uh_alt_prev |
52
 
 *                 |   uh_prev     |    |   uh_prev     |
53
 
 *                 +-----|---------+    +-----|---------+
54
 
 *                       |                    |
55
 
 *                       V                    V
56
 
 *                     NULL             +---------------+    +---------------+
57
 
 *                                      | u_header      |    | u_header      |
58
 
 *                                      |   uh_alt_next ---->|   uh_alt_next |
59
 
 *                                      |   uh_alt_prev |<------ uh_alt_prev |
60
 
 *                                      |   uh_prev     |    |   uh_prev     |
61
 
 *                                      +-----|---------+    +-----|---------+
62
 
 *                                            |                    |
63
 
 *                                           etc.                 etc.
 
40
 *                 +---------------+    +---------------+
 
41
 * b_u_oldhead --->| u_header      |    | u_header      |
 
42
 *                 |   uh_alt_next ---->|   uh_alt_next ----> NULL
 
43
 *         NULL <----- uh_alt_prev |<------ uh_alt_prev |
 
44
 *                 |   uh_prev     |    |   uh_prev     |
 
45
 *                 +-----|---------+    +-----|---------+
 
46
 *                       |                    |
 
47
 *                       V                    V
 
48
 *                 +---------------+    +---------------+
 
49
 *                 | u_header      |    | u_header      |
 
50
 *                 |   uh_alt_next |    |   uh_alt_next |
 
51
 * b_u_newhead --->|   uh_alt_prev |    |   uh_alt_prev |
 
52
 *                 |   uh_prev     |    |   uh_prev     |
 
53
 *                 +-----|---------+    +-----|---------+
 
54
 *                       |                    |
 
55
 *                       V                    V
 
56
 *                     NULL             +---------------+    +---------------+
 
57
 *                                      | u_header      |    | u_header      |
 
58
 *                                      |   uh_alt_next ---->|   uh_alt_next |
 
59
 *                                      |   uh_alt_prev |<------ uh_alt_prev |
 
60
 *                                      |   uh_prev     |    |   uh_prev     |
 
61
 *                                      +-----|---------+    +-----|---------+
 
62
 *                                            |                    |
 
63
 *                                           etc.                 etc.
64
64
 *
65
65
 *
66
66
 * All data is allocated and will all be freed when the buffer is unloaded.
1782
1782
  /* "target" is the node below which we want to be.
1783
1783
   * Init "closest" to a value we can't reach. */
1784
1784
  if (absolute) {
1785
 
    target = step;
 
1785
    if (step == 0) {
 
1786
      // target 0 does not exist, got to 1 and above it.
 
1787
      target = 1;
 
1788
      above = true;
 
1789
    } else {
 
1790
      target = step;
 
1791
    }
1786
1792
    closest = -1;
1787
1793
  } else {
1788
1794
    /* When doing computations with time_t subtract starttime, because