-1

I am reading the code of vim 1.14 and I have some questions about undo.c.

I don't understand the implementation of the undo/redo operation, especially in the function u_undoredo().

I want to know why it uses the link list u_entry?

Conner
  • 30,144
  • 8
  • 52
  • 73

1 Answers1

2

If you checkout the latest version of vim there is an explanation of vim's undo/redo implementation at the top of the undo.c file.

You can read it here.

Each u_entry list contains the information for one undo or redo.

A linked list would make sense for an undo/redo implementation to use since each entry only needs to reference the next or previous entry and can easily be added to efficiently. This is also why vim's undo history creates multiple branches of undo history. Beyond that, I'm not sure what your question is.

Conner
  • 30,144
  • 8
  • 52
  • 73
  • Thanks,I think I need to read the whole vim code to figure out. – toscanininini Jan 27 '14 at 14:45
  • What in particular are you trying to figure out? Are you having trouble understanding what a linked list is and how it's useful? – Conner Jan 27 '14 at 18:53
  • No,I only read undo.c of vim 1.14 without reading any other parts before,and the functions in undo.c confuses me very much. As you said,I can't clarify what my question is,so I think I'd better to figure out the structure of whole vim code before I came for asking. – toscanininini Jan 28 '14 at 04:02
  • Thanks for helping. I'd like to read the code as quickly as I can, and then I will ask if I still have confutions here. – toscanininini Jan 28 '14 at 04:08