diff options
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r-- | src/nvim/quickfix.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index ced0cf0f80..3c945a505b 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2845,6 +2845,39 @@ static char_u *qf_types(int c, int nr) return buf; } +// When "split" is false: Open the entry/result under the cursor. +// When "split" is true: Open the entry/result under the cursor in a new window. +void qf_view_result(bool split) +{ + qf_info_T *qi = &ql_info; + + if (!bt_quickfix(curbuf)) { + return; + } + if (IS_LL_WINDOW(curwin)) { + qi = GET_LOC_LIST(curwin); + } + if (qi == NULL + || qi->qf_lists[qi->qf_curlist].qf_count == 0) { + EMSG(_(e_quickfix)); + return; + } + + if (split) { + char cmd[32]; + + snprintf(cmd, sizeof(cmd), "split +%" PRId64 "%s", + (int64_t)curwin->w_cursor.lnum, + IS_LL_WINDOW(curwin) ? "ll" : "cc"); + if (do_cmdline_cmd(cmd) == OK) { + do_cmdline_cmd("clearjumps"); + } + return; + } + + do_cmdline_cmd((IS_LL_WINDOW(curwin) ? ".ll" : ".cc")); +} + /* * ":cwindow": open the quickfix window if we have errors to display, * close it if not. |