commit 69af1ce2af6a958243b2f85622453f546c1710f9
Author: rani <clagv.randomgames@gmail.com>
Date: Mon Apr 17 19:03:33 2023 +0000
diff --git a/include/commands.h b/include/commands.h
index a10893f..166b35c 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -26 +27 @@
#define _COMMANDS_H
void ext_open(char *);
+long lit_search(long, char *);
long search_file(long, char *);
void create_cuts(char *, char **);
void free_cuts(void);
diff --git a/src/commands.c b/src/commands.c
index 429a254..ee81aa0 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -496 +4928 @@ void ext_open(char * file) {
}
+long lit_search(long c, char * s) {
+ long ret = -1;
+ for (long i = c; i < (signed)n_dir_entries; i++) {
+ if (!strcmp(s, dir_entries[i]->name)) {
+ ret = i;
+ break;
+ }
+ }
+
+ if (ret == -1 && c > 1) {
+ for (long i = 0; i < c; i++) {
+ if (!strcmp(s, dir_entries[i]->name)) {
+ ret = i;
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+
+
long search_file(long c, char * s) {
long ret = -1;
regex_t r;
diff --git a/src/main.c b/src/main.c
index 3fac7c5..dfadc88 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2497 +2497 @@ int main(int argc, char ** argv) {
list_dir(cwd);
// set cursor to old dir
- long lc = search_file(0, cur_dir);
+ long lc = lit_search(0, cur_dir);
if (lc >= 0) {
cursor = lc + 1;
resize_fbufcur(lc);