aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
...
* | | ui_bridge: Fix race condition that results in deadlock.Thiago de Arruda2015-10-31
| | | | | | | | | | | | Fixed by waiting until the UI thread finishes processing events. Close #3541.
* | | os/fs.c: Convert stray getenv() to os_getenv()Michael Reed2015-10-31
| | | | | | | | | | | | | | | | | | | | | This is the last direct getenv() call in the tree (besides the one in os_getenv()); most of the work was already done in [1]. [1]: 412d246be71bd99cb4edde4e6f984b0b0d91bcd9
* | | Merge pull request #3553 from ZyX-I/fix-xdg-2Justin M. Keyes2015-10-30
|\ \ \ | | | | | | | | Some more fixes to XDG code
| * | | undo: Automatically create undo directory if neededZyX2015-10-29
| | | |
| * | | undo: Do some refactoringZyX2015-10-29
| | | | | | | | | | | | | | | | | | | | | | | | Specifically refactor u_get_undo_file_name which will be modified to automatically create undo directory and replace `char_u` with `char` in some of the related functions.
| * | | stdpaths: Document that stdpaths_*_subpath is not returning NULLZyX2015-10-29
| | | |
| * | | stdpaths: Use NULL in place of empty stringsZyX2015-10-29
| | | |
| * | | option: Add current directory to &backupdir optionZyX2015-10-29
| | | | | | | | | | | | | | | | Fixes #3496
* | | | tui: Don't use stderr as an output fallback for the TUIThiago de Arruda2015-10-29
| | | | | | | | | | | | | | | | Ref: https://github.com/neovim/neovim/issues/3547#issuecomment-152156639
* | | | tui: Fix abort when stdout and stderr are not tty.Thiago de Arruda2015-10-29
| | | | | | | | | | | | | | | | | | | | The abort came from using libuv tty handle on non-tty fd. Use uv_pipe_t in these cases. Also add simple test for this case.
* | | | os/input.c: Fix assertion in `create_cursorhold_event`Thiago de Arruda2015-10-29
| | | | | | | | | | | | | | | | The assertion now considers the case where events are disabled.
* | | | Fix 'exrc' optionOvidiu Curcan2015-10-29
|/ / / | | | | | | | | | | | | `do_user_initialization()` ignored changes to the value of the `exrc` option caused by the processing of environment variables or sourcing of files.
* | / option: fix off-by-one error when handling &directoryVictor Adam2015-10-27
| |/ |/| | | | | | | | | | | a8e18d9 introduced an off-by-one error that caused the last character of &directory to be ignored. This commit is a straightforward fix for that error. fixes #3519
* | Merge pull request #3502 from ZyX-I/fix-xdgJustin M. Keyes2015-10-26
|\ \ | | | | | | option: Fix typos that may lead to SEGV in some cases
| * | option: Fix strange condition in add_dir functionZyX2015-10-26
| | |
| * | option: Fix typos that may lead to SEGV in some casesZyX2015-10-26
| | |
* | | edit.c: Fix one clint warningThiago de Arruda2015-10-26
| | |
* | | Start documenting codeThiago de Arruda2015-10-26
| | |
* | | ex_getln: Extract command_line_handle_key from command_line_executeThiago de Arruda2015-10-26
| | |
* | | ex_getln: Convert `cmdline_{not_,}changed` labels into functionsThiago de Arruda2015-10-26
| | |
* | | ex_getln: refactor command line mode to use the `state_enter` loopThiago de Arruda2015-10-26
| | | | | | | | | | | | Split `getcmdline()` into command_line_{enter,check,execute}`
* | | ex_getln: Extract local variables from getcmdline() and fix code styleThiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | Begin refactoring getcmdline() into a state that can be managed by the `state_enter()`: - Move local variables into a local CommandLineState structure - Fix code style in the entire function.
* | | terminal: Refactor to use `state_enter`Thiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | - Create `TerminalState` structure containing data used in terminal mode - Extract `terminal_execute` from `terminal_enter` and use it with `state_enter`.
* | | edit: Extract some functions from `insert_execute`Thiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | - `insert_handle_key`: Contains the big insert mode switch statement. - `insert_do_complete`: Code that used to be in the `docomplete` label. - `insert_do_cindent`: Code that used to be in the `force_cindent` label. Also move some code after the switch statement into the beginning of `insert_check`.
* | | edit: Move most code from `edit()` to `insert_{enter,check,execute}`Thiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor insert mode to use `state_enter` as an event loop: - Move o_lnum(static variable) outside function - Move code before the insert mode loop into `insert_enter` - Move code before `safe_vgetc()` call into `insert_check` - Move code after `safe_vgetc()` call into `insert_execute` - Remove doESCkey label and handle insert mode repeating in the `insert_enter` function - Remove do_intr label(this is not the place for platform-specific interrupt charts)
* | | edit: Extract local variables from edit() and fix code styleThiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | Begin refactoring edit() into a state that can be managed by the `state_enter()`: - Move local variables into a local InsertState structure - Fix code style in the entire function.
* | | normal: Extract some functions from `normal_finish_command`Thiago de Arruda2015-10-26
| | | | | | | | | | | | | | | - `normal_need_redraw_mode_message` - `normal_redraw_mode_message`
* | | normal: Extract `normal_finish_command` from `normal_execute`Thiago de Arruda2015-10-26
| | |
* | | normal: Extract `normal_get_command_count` from `normal_execute`Thiago de Arruda2015-10-26
| | |
* | | normal: Extract some functions from `normal_execute`Thiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | - `normal_handle_special_visual_command` - `normal_need_aditional_char` - `normal_get_additional_char` - `normal_invert_horizontal`
* | | normal: Split `normal_check` into multiple functionsThiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Split most code in `normal_check` in: - `normal_check_stuff_buffer` - `normal_check_interrupt` - `normal_check_cursor_moved` - `normal_check_text_changed` - `normal_check_folds` - `normal_redraw`
* | | main: Start modeling Nvim as pushdown automatonThiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From a very high level point of view, Vim/Nvim can be described as state machines following these instructions in a loop: - Read user input - Peform some action. The action is determined by the current state and can switch states. - Possibly display some feedback to the user. This is not immediately visible because these instructions spread across dozens of nested loops and function calls, making it very hard to modify the state machine(to support more event types, for example). So far, the approach Nvim has taken to allow more events is this: - At the very core function that blocks for input, poll for arbitrary events. - If the event received from the OS is user input, just return it normally to the callers. - If the event is not direct result of user input(possibly a vimscript function call coming from a msgpack-rpc socket or a job control callback), return a special key code(`K_EVENT`) that is handled by callers where it is safer to perform arbitrary actions. One problem with this approach is that the `K_EVENT` signal is being sent across multiple states that may be unaware of it. This was partially fixed with the `input_enable_events`/`input_disable_events` functions, which were added as a mechanism that the upper layers can use to tell the core input functions that it is ready to accept `K_EVENT`. Another problem is that the mapping engine is implemented in getchar.c which is called from every state, but the mapping engine is not aware of `K_EVENT` so events can break mappings. While it is theoretically possible to modify getchar.c to make it aware of `K_EVENT`, this commit fixes the problem with a different approach: Model Nvim as a pushdown automaton(https://en.wikipedia.org/wiki/Pushdown_automaton). This design has many advantages which include: - Decoupling the event loop from the states reponsible for handling events. - Better control of state transition with less dependency on global variable hacks(eg: 'restart_edit' global variable). - Easier removal of global variables and function splitting. That is because many variables are for state-specific information, and probably ended up being global to simplify communication between functions, which we fix by storing state-specific information in specialized structures. The final goal is to let Nvim have a single top-level event loop represented by the following pseudo-code: ``` while not quitting let event = read_event current_state(event) update_screen() ``` This closely mirrors the state machine description above and makes it easier to understand, extend and debug the program. Note that while the pseudo code suggests an explicit stack of states that doesn't rely on return addresses(as suggested by the principles of automata-based programming: https://en.wikipedia.org/wiki/Automata-based_programming), for now we'll use the call stack as a structure to manage state transitioning as it would be very difficult to refactor Nvim to use an explicit stack of states, and the benefits would be small. While this change may seem like an endless amount of work, it is possible to do it incrementally as was shown in the previous commits. The general procedure is: 1- Find a blocking `vgetc()`(or derivatives) call. This call represents an implicit state of the program. 2- Split the code before and after the `vgetc()` call into functions that match the signature of `state_check_callback` and `state_execute_callback. Only `state_execute_callback` is required. 3- Create a `VimState` "subclass" and a initializer function that sets the function pointers and performs any other required initialization steps. If the state has no local variables, just use `VimState` without subclassing. 4- Instead of calling the original function containing the `vgetc()`, initialize a stack-allocated `VimState` subclass, then call `state_enter` to begin processing events in the state. 5- The check/execute callbacks can return 1 to continue normally, 0 to break the loop or -1 to skip to the next iteration. These callbacks contain code that execute before and after the old `vgetc()` call. The functions created in step 2 may contain other `vgetc()` calls. These represent implicit sub-states of the current state, but it is fine to remove them later in smaller steps since we didn't break compatibility with existing code.
* | | main: Refactor normal_enter to call `os_inchar` directlyThiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it impossible for K_EVENT to interfere with mappings, but it also disables processing of events while in the middle of a mapping (Though this will be fixed later as this refactoring progresses). `may_sync_undo` is now called when K_EVENT is received. This is necessary to correctly update undo entry lists before executing some action.
* | | main: Call `normal_execute` from `normal_enter`Thiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `normal_prepare` is now called by `normal_check` before returning 1(to continue). Also remove `input_{enable,disable}_events` calls from `normal_cmd`, which only exists now as a compatibility function to run normal commands with keys inserted into the typeahead buffer(We don't want to process events in these cases anyway).
* | | input: Remove CURSORHOLD keyThiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor input.c, normal.c and edit.c to use the K_EVENT special key to trigger the CURSORHOLD event. In normal and edit mode, K_EVENT is treated as K_CURSORHOLD, which enables better handling of arbitrary actions in those states(eg: In normal mode the previous operator counts will be restored). Also fix a test in vim_spec.lua. The test had a wrong assumption: cmdheight is only used to determine when the press enter screen will be shown, not to limit how many lines or control pagination.
* | | normal: Fix code style in `normal_prepare` and `normal_execute`Thiago de Arruda2015-10-26
| | | | | | | | | | | | | | | This was done separately to make it easier to follow the changes in the previous commit.
* | | normal: Extract most `normal_cmd` logic into two functionsThiago de Arruda2015-10-26
| | | | | | | | | | | | | | | The new functions are `normal_prepare` and `normal_execute` which contain code executed before and after input is received in normal mode.
* | | main: Extract `normal_check` from `main_loop`Thiago de Arruda2015-10-26
|/ / | | | | | | | | | | The new function contains logic that must be executed after handling input in normal mode and also before the first main loop iteration. Also rename `main_loop` to `normal_enter` and move it to normal.c
* | vim-patch:7.4.849Justin M. Keyes2015-10-26
| | | | | | | | | | | | | | | | | | | | Problem: Moving the cursor in Insert mode starts new undo sequence. Solution: Add CTRL-G U to keep the undo sequence for the following cursor movement command. (Christian Brabandt) https://github.com/vim/vim/commit/8b5f65a527c353b9942e362e719687c3a7592309 Closes #3492
* | Merge pull request #3470 from ZyX-I/pr-3198Justin M. Keyes2015-10-25
|\ \ | | | | | | XDG base directory specification support
| * | os/unix_defs: Rename default system vimrc file to sysinit.vimZyX2015-10-24
| | | | | | | | | | | | This way all standard Vim file paths have .vim extension. VIMRC_FILE constant used for &exrc option was not touched.
| * | main: Check init.vim files also in other XDG directoriesZyX2015-10-24
| | |
| * | oldtests: Also set `.` as default directories for old testsZyX2015-10-23
| | |
| * | *: Fix linter errorsZyX2015-10-23
| | |
| * | memline: Automatically create swap file directory for last directoryZyX2015-10-23
| | |
| * | os/fs: Allow os_mkdir_recurse directory name to end with ///ZyX2015-10-23
| | |
| * | option: Use memcnt for counting commasZyX2015-10-23
| | |
| * | stdpaths: Remove outdated commentZyX2015-10-23
| | |
| * | option: Silence “may be used unitialized” errorsZyX2015-10-23
| | |
| * | stdpaths: Add Windows-specific directoriesZyX2015-10-23
| | |