profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/MuhammedZakir/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

pqrs-org/KE-complex_modifications 746

Karabiner-Elements complex_modifications rules

MuhammedZakir/antlr4 0

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

MuhammedZakir/brew 0

🍺 The missing package manager for macOS (or Linux)

MuhammedZakir/brightness 0

Command-line display brightness control for macOS.

MuhammedZakir/caniuse 0

Raw browser/feature support data from caniuse.com

MuhammedZakir/Carp 0

A statically typed lisp, without a GC, for real-time applications.

MuhammedZakir/en.javascript.info 0

Modern JavaScript Tutorial

MuhammedZakir/espanso 0

Cross-platform Text Expander written in Rust

MuhammedZakir/espanso-hub 0

The official espanso package repository

MuhammedZakir/freeCodeCamp 0

freeCodeCamp.org's open source codebase and curriculum. Learn to code at home.

Pull request review commentneovim/neovim

[RFC] Evaluate results of %{} blocks in statusline

 int build_stl_str_hl(           itemisflag = false;         }       }++      // If the output of the expression needs to be evaluated+      // replace the %{} block with the result of evaluation+      if (str != NULL && *str != 0 && strchr((const char *)str, '%') != NULL) {

Does your example not throw E132? That case should be recoverable via set stl= during the more prompt.

shadmansaleh

comment created time in 3 minutes

Pull request review commentneovim/neovim

[RFC] Evaluate results of %{} blocks in statusline

 int build_stl_str_hl(           itemisflag = false;         }       }++      // If the output of the expression needs to be evaluated+      // replace the %{} block with the result of evaluation+      if (str != NULL && *str != 0 && strchr((const char *)str, '%') != NULL) {

I don't think it's necessary as calling something recursively without any end condition is always a bad idea and never ends well .

Even currently

func Hang()
    return Hang()
endfunc
set stl=%!Hang

will hang undefinatly.

shadmansaleh

comment created time in 17 minutes

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);

Done

shadmansaleh

comment created time in 23 minutes

PR opened pychess/pychess

Update metainfo to the latest spec
  • Update to the latest spec per https://freedesktop.org/software/appstream/docs/chap-Quickstart.html
  • Update URLs
  • Add project license and OARS rating
+11 -7

0 comment

1 changed file

pr created time in 24 minutes

Pull request review commentneovim/neovim

[RFC] Evaluate results of %{} blocks in statusline

 int build_stl_str_hl(           itemisflag = false;         }       }++      // If the output of the expression needs to be evaluated+      // replace the %{} block with the result of evaluation+      if (str != NULL && *str != 0 && strchr((const char *)str, '%') != NULL) {

May be a good idea to add an eval limit? Something like this will hang Nvim:

func! Hang() abort
  return "%{Hang()}"
endfunc
set stl=%{Hang()}
shadmansaleh

comment created time in 37 minutes

Pull request review commentneovim/neovim

[RFC] Evaluate results of %{} blocks in statusline

 func Test_statusline()   call assert_match('^vimLineComment\s*$', s:get_statusline())   syntax off +  "%{: evaluates enxpressions present in result of %{} expression
  "%{: evaluates expressions present in result of %{} expression
shadmansaleh

comment created time in 37 minutes

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);

Remove that line? It's a nitpick. The actual issue is STRLEN.

shadmansaleh

comment created time in an hour

issue openedKethku/neovide

Font specification doesn't allow for overwriting of specific font types

While I know that this is a part of #444, there is a specific issue with this problem that I haven't seen brought up

I use FiraCode Nerd Font, and this font does not have Italic and Bold Italic fonts. The font instead just defaults to non-italic. Normally I specify an italic and bold italic font in my terminal, but with Neovide (and GUI NeoVim in general), since FiraCode NF maps non-italic fonts to italic fonts, I can no longer see italics regardless if I also specify another font like so:

set guifont=FiraCode\ Nerd\ Font:h15,\ MesloLGS\ NF:h15,DejavuSans:h15

For kitty for instance (my terminal), the config for specific fonts per type is something like this:

font_family FiraCode Nerd Font
bold_font auto
italic_font Meslo LG S NF Italic
bold_italic_font Meslo LG S NF Bold Italic

I wonder if this could be addressed with future updates to Neovide. I really like this GUI but this limitation hurts some of my usage

created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 func Test_search_stat()   set shortmess-=S   " Append 50 lines with text to search for, "foobar" appears 20 times   call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10))+  call nvim_win_set_cursor(0, [1, 0])++  " searchcount() returns an empty dictionary when previous pattern was not set+  call assert_equal({}, searchcount(#{pattern: ''}))+  " but setting @/ should also work (even 'n' nor 'N' was executed)+  " recompute the count when the last position is different.+  call assert_equal(+    \ #{current: 1, exact_match: 1, total: 40, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'foo'}))+  call assert_equal(+    \ #{current: 0, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar'}))+  call assert_equal(+    \ #{current: 0, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [2, 1, 0]}))+  call assert_equal(+    \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [3, 1, 0]}))+  " on last char of match+  call assert_equal(+    \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [3, 9, 0]}))+  " on char after match+  call assert_equal(+    \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [3, 10, 0]}))+  call assert_equal(+    \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0]}))+  call assert_equal(+    \ #{current: 1, exact_match: 0, total: 2, incomplete: 2, maxcount: 1},+    \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0], maxcount: 1}))+  call assert_equal(+    \ #{current: 0, exact_match: 0, total: 2, incomplete: 2, maxcount: 1},+    \ searchcount(#{pattern: 'fooooobar', maxcount: 1}))    " match at second line   call cursor(1, 1)
 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.
shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                bool show_top_bot_msg, char_u  *msgbuf,+                                bool recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);+      if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {+        memmove(t + 2, t, len);+        t[0] = 'W';+        t[1] = ' ';+        len += 2;+      }++      memmove(msgbuf + STRLEN(msgbuf) - len, t, len);+      if (dirc == '?' && stat.cur == maxcount + 1) {+        stat.cur = -1;+      }++      // keep the message even after redraw, but don't put in history+      msg_hist_off = true;+      msg_ext_set_kind("search_count");+      give_warning(msgbuf, false);+      msg_hist_off = false;+    }+}++// Add the search count information to "stat".+// "stat" must not be NULL.+// When "recompute" is true always recompute the numbers.+// dirc == 0: don't find the next/previous match (only set the result to "stat")+// dirc == '/': find the next match+// dirc == '?': find the previous match+static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                               searchstat_T *stat, bool recompute, int maxcount,+                               long timeout)+{+    int             save_ws = p_ws;+    bool             wraparound = false;+    pos_T           p = (*pos);+    static pos_T    lastpos = { 0, 0, 0 };     static int      cur = 0;     static int      cnt = 0;+    static bool      exact_match = false;+    static int      incomplete = 0;+    static int      last_maxcount = SEARCH_STAT_DEF_MAX_COUNT;     static int      chgtick = 0;     static char_u   *lastpat = NULL;     static buf_T    *lbuf = NULL;-    proftime_T  start;-#define OUT_OF_TIME 999+    proftime_T      start; +    memset(stat, 0, sizeof(searchstat_T));++    if (dirc == 0 && !recompute && !EMPTY_POS(lastpos)) {+      stat->cur = cur;+      stat->cnt = cnt;+      stat->exact_match = exact_match;+      stat->incomplete = incomplete;+      stat->last_maxcount = last_maxcount;+      return;+    }+    last_maxcount = maxcount;     wraparound = ((dirc == '?' && lt(lastpos, p))                   || (dirc == '/' && lt(p, lastpos)));      // If anything relevant changed the count has to be recomputed.     // STRNICMP ignores case, but we should not ignore case.     // Unfortunately, there is no STRNICMP function.+    // XXX: above comment should be "no MB_STRCMP function" ?     if (!(chgtick == buf_get_changedtick(curbuf)           && lastpat != NULL  // supress clang/NULL passed as nonnull parameter           && STRNICMP(lastpat, spats[last_idx].pat, STRLEN(lastpat)) == 0           && STRLEN(lastpat) == STRLEN(spats[last_idx].pat)-          && equalpos(lastpos, curwin->w_cursor)+          && equalpos(lastpos, *cursor_pos)           && lbuf == curbuf)-        || wraparound || cur < 0 || cur > 99 || recompute) {+        || wraparound || cur < 0 || (maxcount > 0 && cur > maxcount)+        || recompute) {       cur = 0;       cnt = 0;+      exact_match = false;+      incomplete = 0;       clearpos(&lastpos);       lbuf = curbuf;     } -    if (equalpos(lastpos, curwin->w_cursor) && !wraparound-        && (dirc == '/' ? cur < cnt : cur > 0)) {-      cur += dirc == '/' ? 1 : -1;+    if (equalpos(lastpos, *cursor_pos) && !wraparound+        && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 0)) {+      cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1;     } else {+      bool done_search = false;+      pos_T endpos = { 0, 0, 0 };       p_ws = false;-      start = profile_setlimit(20L);-      while (!got_int && searchit(curwin, curbuf, &lastpos, NULL,+      if (timeout > 0) {+        start  = profile_setlimit(timeout);+      }+      while (!got_int && searchit(curwin, curbuf, &lastpos, &endpos,                                   FORWARD, NULL, 1, SEARCH_KEEP, RE_LAST,                                   NULL) != FAIL) {+        done_search = true;         // Stop after passing the time limit.-        if (profile_passed_limit(start)) {-          cnt = OUT_OF_TIME;-          cur = OUT_OF_TIME;+        if (timeout > 0 && profile_passed_limit(start)) {+          incomplete = 1;           break;         }         cnt++;         if (ltoreq(lastpos, p)) {-          cur++;+          cur = cnt;+          if (lt(p, endpos)) {+            exact_match = true;+          }         }         fast_breakcheck();-        if (cnt > 99) {+        if (maxcount > 0 && cnt > maxcount) {+          incomplete = 2;    // max count exceeded           break;         }       }       if (got_int) {         cur = -1;  // abort       }+      if (done_search) {+        xfree(lastpat);+        lastpat = vim_strsave(spats[last_idx].pat);+        chgtick = buf_get_changedtick(curbuf);+        lbuf = curbuf;+        lastpos = p;+      }     }-    if (cur > 0) {-      char t[SEARCH_STAT_BUF_LEN] = "";-      int len;+    stat->cur = cur;+    stat->cnt = cnt;+    stat->exact_match = exact_match;+    stat->incomplete = incomplete;+    stat->last_maxcount = last_maxcount;+    p_ws = save_ws;+} -      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {-        if (cur == OUT_OF_TIME) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?\?/?]");-        } else if (cnt > 99 && cur > 99) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>99/>99]");-        } else if (cnt > 99) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>99/%d]", cur);-        } else {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]", cnt, cur);+// "searchcount()" function+void f_searchcount(typval_T *argvars, typval_T *rettv, FunPtr fptr)+{+    pos_T   pos = curwin->w_cursor;+    char_u    *pattern = NULL;+    int     maxcount = SEARCH_STAT_DEF_MAX_COUNT;+    long    timeout = SEARCH_STAT_DEF_TIMEOUT;+    bool     recompute = true;+    searchstat_T  stat;++    tv_dict_alloc_ret(rettv);++    if (shortmess(SHM_SEARCHCOUNT)) {  // 'shortmess' contains 'S' flag+      recompute = true;+    }++    if (argvars[0].v_type != VAR_UNKNOWN) {+      dict_T    *dict;+      dictitem_T  *di;+      listitem_T  *li;+      bool error = false;++      if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) {+        EMSG(_(e_dictreq));+        return;+      }+      dict = argvars[0].vval.v_dict;+      di = tv_dict_find(dict, (const char *)"timeout", -1);+      if (di != NULL) {+        timeout = (long)tv_get_number_chk(&di->di_tv, &error);+        if (error) {+          return;         }-      } else {-        if (cur == OUT_OF_TIME) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");-        } else if (cnt > 99 && cur > 99) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>99/>99]");-        } else if (cnt > 99) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>99]", cur);-        } else {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]", cur, cnt);+      }+      di = tv_dict_find(dict, (const char *)"maxcount", -1);+      if (di != NULL) {+        maxcount = (int)tv_get_number_chk(&di->di_tv, &error);+        if (error) {+          return;         }       }--      len = STRLEN(t);-      if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {-        memmove(t + 2, t, len);-        t[0] = 'W';-        t[1] = ' ';-        len += 2;+      di = tv_dict_find(dict, (const char *)"recompute", -1);+      if (di != NULL) {+        recompute = tv_get_number_chk(&di->di_tv, &error);

I think that patch isn't in this pr. I couldn't find replacement of dict_get_number and that patch was about running test in vim9 so I didn't port it

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 func Test_search_stat()   set shortmess-=S   " Append 50 lines with text to search for, "foobar" appears 20 times   call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10))+  call nvim_win_set_cursor(0, [1, 0])++  " searchcount() returns an empty dictionary when previous pattern was not set+  call assert_equal({}, searchcount(#{pattern: ''}))+  " but setting @/ should also work (even 'n' nor 'N' was executed)+  " recompute the count when the last position is different.+  call assert_equal(+    \ #{current: 1, exact_match: 1, total: 40, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'foo'}))+  call assert_equal(+    \ #{current: 0, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar'}))+  call assert_equal(+    \ #{current: 0, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [2, 1, 0]}))+  call assert_equal(+    \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [3, 1, 0]}))+  " on last char of match+  call assert_equal(+    \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [3, 9, 0]}))+  " on char after match+  call assert_equal(+    \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [3, 10, 0]}))+  call assert_equal(+    \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99},+    \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0]}))+  call assert_equal(+    \ #{current: 1, exact_match: 0, total: 2, incomplete: 2, maxcount: 1},+    \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0], maxcount: 1}))+  call assert_equal(+    \ #{current: 0, exact_match: 0, total: 2, incomplete: 2, maxcount: 1},+    \ searchcount(#{pattern: 'fooooobar', maxcount: 1}))    " match at second line   call cursor(1, 1)

I guess call nvim_win_set_cursor(0, [1, 0]) is suppose to replace this line. Why?

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                bool show_top_bot_msg, char_u  *msgbuf,+                                bool recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);+      if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {+        memmove(t + 2, t, len);+        t[0] = 'W';+        t[1] = ' ';+        len += 2;+      }++      memmove(msgbuf + STRLEN(msgbuf) - len, t, len);+      if (dirc == '?' && stat.cur == maxcount + 1) {+        stat.cur = -1;+      }++      // keep the message even after redraw, but don't put in history+      msg_hist_off = true;+      msg_ext_set_kind("search_count");+      give_warning(msgbuf, false);+      msg_hist_off = false;+    }+}++// Add the search count information to "stat".+// "stat" must not be NULL.+// When "recompute" is true always recompute the numbers.+// dirc == 0: don't find the next/previous match (only set the result to "stat")+// dirc == '/': find the next match+// dirc == '?': find the previous match+static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                               searchstat_T *stat, bool recompute, int maxcount,+                               long timeout)+{+    int             save_ws = p_ws;+    bool             wraparound = false;+    pos_T           p = (*pos);+    static pos_T    lastpos = { 0, 0, 0 };     static int      cur = 0;     static int      cnt = 0;+    static bool      exact_match = false;+    static int      incomplete = 0;+    static int      last_maxcount = SEARCH_STAT_DEF_MAX_COUNT;     static int      chgtick = 0;     static char_u   *lastpat = NULL;     static buf_T    *lbuf = NULL;-    proftime_T  start;-#define OUT_OF_TIME 999+    proftime_T      start; +    memset(stat, 0, sizeof(searchstat_T));++    if (dirc == 0 && !recompute && !EMPTY_POS(lastpos)) {+      stat->cur = cur;+      stat->cnt = cnt;+      stat->exact_match = exact_match;+      stat->incomplete = incomplete;+      stat->last_maxcount = last_maxcount;+      return;+    }+    last_maxcount = maxcount;     wraparound = ((dirc == '?' && lt(lastpos, p))                   || (dirc == '/' && lt(p, lastpos)));      // If anything relevant changed the count has to be recomputed.     // STRNICMP ignores case, but we should not ignore case.     // Unfortunately, there is no STRNICMP function.+    // XXX: above comment should be "no MB_STRCMP function" ?     if (!(chgtick == buf_get_changedtick(curbuf)           && lastpat != NULL  // supress clang/NULL passed as nonnull parameter           && STRNICMP(lastpat, spats[last_idx].pat, STRLEN(lastpat)) == 0           && STRLEN(lastpat) == STRLEN(spats[last_idx].pat)-          && equalpos(lastpos, curwin->w_cursor)+          && equalpos(lastpos, *cursor_pos)           && lbuf == curbuf)-        || wraparound || cur < 0 || cur > 99 || recompute) {+        || wraparound || cur < 0 || (maxcount > 0 && cur > maxcount)+        || recompute) {       cur = 0;       cnt = 0;+      exact_match = false;+      incomplete = 0;       clearpos(&lastpos);       lbuf = curbuf;     } -    if (equalpos(lastpos, curwin->w_cursor) && !wraparound-        && (dirc == '/' ? cur < cnt : cur > 0)) {-      cur += dirc == '/' ? 1 : -1;+    if (equalpos(lastpos, *cursor_pos) && !wraparound+        && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 0)) {+      cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1;     } else {+      bool done_search = false;+      pos_T endpos = { 0, 0, 0 };       p_ws = false;-      start = profile_setlimit(20L);-      while (!got_int && searchit(curwin, curbuf, &lastpos, NULL,+      if (timeout > 0) {+        start  = profile_setlimit(timeout);+      }+      while (!got_int && searchit(curwin, curbuf, &lastpos, &endpos,                                   FORWARD, NULL, 1, SEARCH_KEEP, RE_LAST,                                   NULL) != FAIL) {+        done_search = true;         // Stop after passing the time limit.-        if (profile_passed_limit(start)) {-          cnt = OUT_OF_TIME;-          cur = OUT_OF_TIME;+        if (timeout > 0 && profile_passed_limit(start)) {+          incomplete = 1;           break;         }         cnt++;         if (ltoreq(lastpos, p)) {-          cur++;+          cur = cnt;+          if (lt(p, endpos)) {+            exact_match = true;+          }         }         fast_breakcheck();-        if (cnt > 99) {+        if (maxcount > 0 && cnt > maxcount) {+          incomplete = 2;    // max count exceeded           break;         }       }       if (got_int) {         cur = -1;  // abort       }+      if (done_search) {+        xfree(lastpat);+        lastpat = vim_strsave(spats[last_idx].pat);+        chgtick = buf_get_changedtick(curbuf);+        lbuf = curbuf;+        lastpos = p;+      }     }-    if (cur > 0) {-      char t[SEARCH_STAT_BUF_LEN] = "";-      int len;+    stat->cur = cur;+    stat->cnt = cnt;+    stat->exact_match = exact_match;+    stat->incomplete = incomplete;+    stat->last_maxcount = last_maxcount;+    p_ws = save_ws;+} -      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {-        if (cur == OUT_OF_TIME) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?\?/?]");-        } else if (cnt > 99 && cur > 99) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>99/>99]");-        } else if (cnt > 99) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>99/%d]", cur);-        } else {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]", cnt, cur);+// "searchcount()" function+void f_searchcount(typval_T *argvars, typval_T *rettv, FunPtr fptr)+{+    pos_T   pos = curwin->w_cursor;+    char_u    *pattern = NULL;+    int     maxcount = SEARCH_STAT_DEF_MAX_COUNT;+    long    timeout = SEARCH_STAT_DEF_TIMEOUT;+    bool     recompute = true;+    searchstat_T  stat;++    tv_dict_alloc_ret(rettv);++    if (shortmess(SHM_SEARCHCOUNT)) {  // 'shortmess' contains 'S' flag+      recompute = true;+    }++    if (argvars[0].v_type != VAR_UNKNOWN) {+      dict_T    *dict;+      dictitem_T  *di;+      listitem_T  *li;+      bool error = false;++      if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) {+        EMSG(_(e_dictreq));+        return;+      }+      dict = argvars[0].vval.v_dict;+      di = tv_dict_find(dict, (const char *)"timeout", -1);+      if (di != NULL) {+        timeout = (long)tv_get_number_chk(&di->di_tv, &error);+        if (error) {+          return;         }-      } else {-        if (cur == OUT_OF_TIME) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");-        } else if (cnt > 99 && cur > 99) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>99/>99]");-        } else if (cnt > 99) {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>99]", cur);-        } else {-          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]", cur, cnt);+      }+      di = tv_dict_find(dict, (const char *)"maxcount", -1);+      if (di != NULL) {+        maxcount = (int)tv_get_number_chk(&di->di_tv, &error);+        if (error) {+          return;         }       }--      len = STRLEN(t);-      if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {-        memmove(t + 2, t, len);-        t[0] = 'W';-        t[1] = ' ';-        len += 2;+      di = tv_dict_find(dict, (const char *)"recompute", -1);+      if (di != NULL) {+        recompute = tv_get_number_chk(&di->di_tv, &error);

Vim changes this to use dict_get_bool which should be tv_dict_get_bool in Neovim.

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);+      if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {+        memmove(t + 2, t, len);+        t[0] = 'W';+        t[1] = ' ';+        len += 2;+      }++      memmove(msgbuf + STRLEN(msgbuf) - len, t, len);+      if (dirc == '?' && stat.cur == maxcount + 1) {+        stat.cur = -1;+      }++      // keep the message even after redraw, but don't put in history+      msg_hist_off = true;+      msg_ext_set_kind("search_count");+      give_warning(msgbuf, false);+      msg_hist_off = false;+    }+}++// Add the search count information to "stat".+// "stat" must not be NULL.+// When "recompute" is TRUE always recompute the numbers.+// dirc == 0: don't find the next/previous match (only set the result to "stat")+// dirc == '/': find the next match+// dirc == '?': find the previous match+static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                               searchstat_T *stat, int recompute, int maxcount,+                               long timeout)+{+    int             save_ws = p_ws;+    int             wraparound = false;+    pos_T           p = (*pos);+    static pos_T    lastpos = { 0, 0, 0 };     static int      cur = 0;     static int      cnt = 0;+    static int      exact_match = false;+    static int      incomplete = 0;+    static int      last_maxcount = SEARCH_STAT_DEF_MAX_COUNT;     static int      chgtick = 0;     static char_u   *lastpat = NULL;     static buf_T    *lbuf = NULL;-    proftime_T  start;-#define OUT_OF_TIME 999+    proftime_T      start; +    memset(stat, 0, sizeof(searchstat_T));++    if (dirc == 0 && !recompute && !EMPTY_POS(lastpos)) {+      stat->cur = cur;+      stat->cnt = cnt;+      stat->exact_match = exact_match;+      stat->incomplete = incomplete;+      stat->last_maxcount = last_maxcount;+      return;+    }+    last_maxcount = maxcount;     wraparound = ((dirc == '?' && lt(lastpos, p))                   || (dirc == '/' && lt(p, lastpos)));      // If anything relevant changed the count has to be recomputed.     // STRNICMP ignores case, but we should not ignore case.     // Unfortunately, there is no STRNICMP function.+    // XXX: above comment should be "no MB_STRCMP function" ?     if (!(chgtick == buf_get_changedtick(curbuf)           && lastpat != NULL  // supress clang/NULL passed as nonnull parameter           && STRNICMP(lastpat, spats[last_idx].pat, STRLEN(lastpat)) == 0           && STRLEN(lastpat) == STRLEN(spats[last_idx].pat)-          && equalpos(lastpos, curwin->w_cursor)+          && equalpos(lastpos, *cursor_pos)           && lbuf == curbuf)-        || wraparound || cur < 0 || cur > 99 || recompute) {+        || wraparound || cur < 0 || (maxcount > 0 && cur > maxcount)+        || recompute) {       cur = 0;       cnt = 0;+      exact_match = false;+      incomplete = 0;       clearpos(&lastpos);       lbuf = curbuf;     } -    if (equalpos(lastpos, curwin->w_cursor) && !wraparound-        && (dirc == '/' ? cur < cnt : cur > 0)) {-      cur += dirc == '/' ? 1 : -1;+    if (equalpos(lastpos, *cursor_pos) && !wraparound+        && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 0)) {+      cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1;     } else {+      int done_search = false;

I've changed this and few more to bool . See diff of last commit

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);+      if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {+        memmove(t + 2, t, len);+        t[0] = 'W';+        t[1] = ' ';+        len += 2;+      }++      memmove(msgbuf + STRLEN(msgbuf) - len, t, len);+      if (dirc == '?' && stat.cur == maxcount + 1) {+        stat.cur = -1;+      }++      // keep the message even after redraw, but don't put in history+      msg_hist_off = true;+      msg_ext_set_kind("search_count");+      give_warning(msgbuf, false);+      msg_hist_off = false;+    }+}++// Add the search count information to "stat".+// "stat" must not be NULL.+// When "recompute" is TRUE always recompute the numbers.+// dirc == 0: don't find the next/previous match (only set the result to "stat")+// dirc == '/': find the next match+// dirc == '?': find the previous match+static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                               searchstat_T *stat, int recompute, int maxcount,+                               long timeout)+{+    int             save_ws = p_ws;+    int             wraparound = false;+    pos_T           p = (*pos);+    static pos_T    lastpos = { 0, 0, 0 };     static int      cur = 0;     static int      cnt = 0;+    static int      exact_match = false;

because I'm blind 🤦‍♂️

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);

But len is alrwady declared as size_t at line 4361

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);+      if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {+        memmove(t + 2, t, len);+        t[0] = 'W';+        t[1] = ' ';+        len += 2;+      }++      memmove(msgbuf + STRLEN(msgbuf) - len, t, len);+      if (dirc == '?' && stat.cur == maxcount + 1) {+        stat.cur = -1;+      }++      // keep the message even after redraw, but don't put in history+      msg_hist_off = true;+      msg_ext_set_kind("search_count");+      give_warning(msgbuf, false);+      msg_hist_off = false;+    }+}++// Add the search count information to "stat".+// "stat" must not be NULL.+// When "recompute" is TRUE always recompute the numbers.+// dirc == 0: don't find the next/previous match (only set the result to "stat")+// dirc == '/': find the next match+// dirc == '?': find the previous match+static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                               searchstat_T *stat, int recompute, int maxcount,+                               long timeout)+{+    int             save_ws = p_ws;+    int             wraparound = false;+    pos_T           p = (*pos);+    static pos_T    lastpos = { 0, 0, 0 };     static int      cur = 0;     static int      cnt = 0;+    static int      exact_match = false;+    static int      incomplete = 0;+    static int      last_maxcount = SEARCH_STAT_DEF_MAX_COUNT;     static int      chgtick = 0;     static char_u   *lastpat = NULL;     static buf_T    *lbuf = NULL;-    proftime_T  start;-#define OUT_OF_TIME 999+    proftime_T      start; +    memset(stat, 0, sizeof(searchstat_T));++    if (dirc == 0 && !recompute && !EMPTY_POS(lastpos)) {+      stat->cur = cur;+      stat->cnt = cnt;+      stat->exact_match = exact_match;+      stat->incomplete = incomplete;+      stat->last_maxcount = last_maxcount;+      return;+    }+    last_maxcount = maxcount;     wraparound = ((dirc == '?' && lt(lastpos, p))                   || (dirc == '/' && lt(p, lastpos)));      // If anything relevant changed the count has to be recomputed.     // STRNICMP ignores case, but we should not ignore case.     // Unfortunately, there is no STRNICMP function.+    // XXX: above comment should be "no MB_STRCMP function" ?     if (!(chgtick == buf_get_changedtick(curbuf)           && lastpat != NULL  // supress clang/NULL passed as nonnull parameter           && STRNICMP(lastpat, spats[last_idx].pat, STRLEN(lastpat)) == 0           && STRLEN(lastpat) == STRLEN(spats[last_idx].pat)-          && equalpos(lastpos, curwin->w_cursor)+          && equalpos(lastpos, *cursor_pos)           && lbuf == curbuf)-        || wraparound || cur < 0 || cur > 99 || recompute) {+        || wraparound || cur < 0 || (maxcount > 0 && cur > maxcount)+        || recompute) {       cur = 0;       cnt = 0;+      exact_match = false;+      incomplete = 0;       clearpos(&lastpos);       lbuf = curbuf;     } -    if (equalpos(lastpos, curwin->w_cursor) && !wraparound-        && (dirc == '/' ? cur < cnt : cur > 0)) {-      cur += dirc == '/' ? 1 : -1;+    if (equalpos(lastpos, *cursor_pos) && !wraparound+        && (dirc == 0 || dirc == '/' ? cur < cnt : cur > 0)) {+      cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1;     } else {+      int done_search = false;

bool

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);+      if (show_top_bot_msg && len + 2 < SEARCH_STAT_BUF_LEN) {+        memmove(t + 2, t, len);+        t[0] = 'W';+        t[1] = ' ';+        len += 2;+      }++      memmove(msgbuf + STRLEN(msgbuf) - len, t, len);+      if (dirc == '?' && stat.cur == maxcount + 1) {+        stat.cur = -1;+      }++      // keep the message even after redraw, but don't put in history+      msg_hist_off = true;+      msg_ext_set_kind("search_count");+      give_warning(msgbuf, false);+      msg_hist_off = false;+    }+}++// Add the search count information to "stat".+// "stat" must not be NULL.+// When "recompute" is TRUE always recompute the numbers.+// dirc == 0: don't find the next/previous match (only set the result to "stat")+// dirc == '/': find the next match+// dirc == '?': find the previous match+static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                               searchstat_T *stat, int recompute, int maxcount,+                               long timeout)+{+    int             save_ws = p_ws;+    int             wraparound = false;+    pos_T           p = (*pos);+    static pos_T    lastpos = { 0, 0, 0 };     static int      cur = 0;     static int      cnt = 0;+    static int      exact_match = false;

It's documented as a boolean. exact_match uses true/false values only. Why is this int?

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout) {-    int       save_ws = p_ws;-    int       wraparound = false;-    pos_T     p = (*pos);-    static  pos_T   lastpos = { 0, 0, 0 };+    searchstat_T stat;++    update_search_stat(dirc, pos, cursor_pos, &stat, recompute, maxcount,+                       timeout);+    if (stat.cur > 0) {+      char  t[SEARCH_STAT_BUF_LEN];+      size_t  len;++      if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/%d]",+                       maxcount, stat.cur);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cnt, stat.cur);+        }+      } else {+        if (stat.incomplete == 1) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[?/??]");+        } else if (stat.cnt > maxcount && stat.cur > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[>%d/>%d]",+                       maxcount, maxcount);+        } else if (stat.cnt > maxcount) {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/>%d]",+                       stat.cur, maxcount);+        } else {+          vim_snprintf(t, SEARCH_STAT_BUF_LEN, "[%d/%d]",+                       stat.cur, stat.cnt);+        }+      }++      len = STRLEN(t);

size_t len = strlen(t); because t is char type.

shadmansaleh

comment created time in an hour

issue commentHammerspoon/hammerspoon

With the latest BigSur update (11.3 20E232) hs.eventtap.keyStrokes no longer works on web forms in password protected fields

yeah, in Terminal.app, with Secure Keyboard Entry enabled, it fails as well

sfosdal

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout)

changed . + recompute in update_search_state changed to bool

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,

updated

shadmansaleh

comment created time in an hour

issue commentneovim/neovim

Too wide hard tabs by default

Could you be so kind and tell about those scenarios, because I can't really come up with any of such?

Only everything other than a text editor with configurable tab width.

Not to mention that using different tab widths is a false nirvana anyway, since most people still tend to align text after the indent with spaces. That means that any tab width other than the one that was in use by the person doing the aligning is going to be wrong.

As you suggest, tab width is a subjective thing, so why should we impose anything other than the default value on our users? People/projects can choose to use a non-default value as they please.

many, if not majority of free software projects have weird defaults

There's nothing weird about a tab stop of 8. There probably are defaults that could be reasonably argued as weird, but tab stop being 8 is not one of them.

Personally, I see it as an example of gatekeeping.

The fact that we let you configure tab stop but don't want to change the default value to your preferred value (which would only upset the next person) is gatekeeping? Adding set tabstop=4 to your init.vim is "extensive configuration"?

Anyway, real programmers don't use tabs for indenting. That reduces the size of their files, and every byte counts!

Logarithmus

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int do_search(         && c != FAIL         && !shortmess(SHM_SEARCHCOUNT)         && msgbuf != NULL) {-      search_stat(dirc, &pos, show_top_bot_msg, msgbuf,

Oops forgot it was moved to search.h . Deleted .

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,+                                int recompute, int maxcount, long timeout)

bool recompute is correct.

In general, don't change bool (or TriState) to int unless int values are used. If int values are used, then always use int values even if Vim uses FALSE and TRUE for int parameters.

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int linewhite(linenr_T lnum) }  // Add the search count "[3/19]" to "msgbuf".-// When "recompute" is true Always recompute the numbers.-static void search_stat(int dirc, pos_T *pos,-                        bool show_top_bot_msg, char_u *msgbuf, bool recompute)+// See update_search_stat() for other arguments.+static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,+                                int show_top_bot_msg, char_u  *msgbuf,

bool show_top_bot_msg is correct.

shadmansaleh

comment created time in an hour

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 int do_search(         && c != FAIL         && !shortmess(SHM_SEARCHCOUNT)         && msgbuf != NULL) {-      search_stat(dirc, &pos, show_top_bot_msg, msgbuf,

#define SEARCH_STAT_BUF_LEN 12 wasn't deleted on line 1045.

shadmansaleh

comment created time in 2 hours

PR opened smolck/uivonim

Handle redraw events on main thread (sorta)

ATM all redraw events are serialized as JSON and then sent over IPC to the renderer thread, where they are decoded and handled. This isn't really ideal, the most notable reason why being that if too much is sent over in a single redraw notif from neovim, uivonim will freeze up since the JSON parsing will fail due to it being too much.

The goal of this PR is to fix that by handling as much as possible of the render events on the main thread (ideally, at least), and then sending over as little information as possible (again, ideally) to the render thread. This way, JSON can hopefully be avoided entirely as electron's IPC magic can handle everything, and also it should fix the issue described above.

I have my doubts whether or not this will work once I've moved as much as I can/am willing to move over to the main thread, but we'll see. Draft for now since I only just started.

+336 -175

0 comment

7 changed files

pr created time in 2 hours

create barnchsmolck/uivonim

branch : parse-redraw-on-main

created branch time in 2 hours

Pull request review commentneovim/neovim

vim-patch:8.2.{0877, 0880, 0884, 0887, 0896} - port searchcount()

 search({pattern} [, {flags} [, {stopline} [, {timeout}]]])	*search()* 		The 'n' flag tells the function not to move the cursor.  +searchcount([{options}])					*searchcount()*

Nice catch . Added :)

shadmansaleh

comment created time in 2 hours