mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 06:16:08 +00:00
vim-patch:8.2.0877: cannot get the search statistics
Problem: Cannot get the search statistics.
Solution: Add the searchcount() function. (Fujiwara Takuya, closes vim/vim#4446)
e8f5ec0d30
Additional changes:
- Tests weren't passing because the test ran assuming the cursor was at
start of buffer but append() left the cursor at end of buffer .
So cursor is moved to start of buffer after append.
- searchcount() added to list of builtin functions.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/buffer_defs.h"
|
||||
#include "nvim/eval/funcs.h"
|
||||
#include "nvim/eval/typval.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/os/time.h"
|
||||
@@ -49,6 +50,11 @@
|
||||
#define RE_BOTH 2 /* save pat in both patterns */
|
||||
#define RE_LAST 2 /* use last used pattern if "pat" is NULL */
|
||||
|
||||
// Values for searchcount()
|
||||
#define SEARCH_STAT_DEF_TIMEOUT 20L
|
||||
#define SEARCH_STAT_DEF_MAX_COUNT 99
|
||||
#define SEARCH_STAT_BUF_LEN 12
|
||||
|
||||
/// Structure containing offset definition for the last search pattern
|
||||
///
|
||||
/// @note Only offset for the last search pattern is used, not for the last
|
||||
@@ -78,6 +84,16 @@ typedef struct {
|
||||
int sa_wrapped; ///< search wrapped around
|
||||
} searchit_arg_T;
|
||||
|
||||
typedef struct searchstat
|
||||
{
|
||||
int cur; // current position of found words
|
||||
int cnt; // total count of found words
|
||||
int exact_match; // TRUE if matched exactly on specified position
|
||||
int incomplete; // 0: search was fully completed
|
||||
// 1: recomputing was timed out
|
||||
// 2: max count exceeded
|
||||
int last_maxcount; // the max count of the last search
|
||||
} searchstat_T;
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "search.h.generated.h"
|
||||
|
Reference in New Issue
Block a user