Skip to content

Instantly share code, notes, and snippets.

@norio13
Created August 3, 2017 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norio13/c8b8e6bbdb1c3c11ac63a257e8ae1bac to your computer and use it in GitHub Desktop.
Save norio13/c8b8e6bbdb1c3c11ac63a257e8ae1bac to your computer and use it in GitHub Desktop.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index fc0e05dad..8a8355c66 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -13,6 +13,7 @@
#define USING_FLOAT_STUFF
#include "vim.h"
+#include "stdio.h"
#if defined(FEAT_EVAL) || defined(PROTO)
@@ -900,6 +901,16 @@ static struct fst
{"xor", 2, 2, f_xor},
};
+
+void debug_append_evalfunc(char *filename, char *text)
+{
+ FILE *fp = fopen(filename, "a");
+ if (fp != NULL) {
+ fprintf(fp, "%s\n", text);
+ fclose(fp);
+ }
+}
+
#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
/*
@@ -3207,6 +3218,7 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
if (check_secure())
return;
+ debug_append_ops("log", "evalfunc.c:f_feedkeys START");
keys = get_tv_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
@@ -3258,6 +3270,7 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
}
}
}
+ debug_append_ops("log", "evalfunc.c:f_feedkeys END");
}
/*
diff --git a/src/normal.c b/src/normal.c
index d655c7467..44515332c 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -13,6 +13,7 @@
*/
#include "vim.h"
+#include "stdio.h"
/*
* The Visual area is remembered for reselection.
@@ -439,6 +440,14 @@ static short nv_cmd_idx[NV_CMDS_SIZE];
* nv_cmds[idx].cmd_char == nv_cmd_idx[nv_cmds[idx].cmd_char] */
static int nv_max_linear;
+void debug_append_normal(char *filename, char *text)
+{
+ FILE *fp = fopen(filename, "a");
+ if (fp != NULL) {
+ fprintf(fp, "%s\n", text);
+ fclose(fp);
+ }
+}
/*
* Compare functions for qsort() below, that checks the command character
* through the index in nv_cmd_idx[].
@@ -557,6 +566,7 @@ normal_cmd(
int set_prevcount = FALSE;
#endif
+ debug_append_normal("log", "normal.c:normal_cmd START");
vim_memset(&ca, 0, sizeof(ca)); /* also resets ca.retval */
ca.oap = oap;
@@ -1220,6 +1230,7 @@ getcount:
{
int save_State = State;
+ debug_append_normal("log", "normal.c:normal_cmd 1");
/* Draw the cursor with the right shape here */
if (restart_edit != 0)
State = INSERT;
@@ -1230,6 +1241,7 @@ getcount:
{
char_u *kmsg;
+ debug_append_normal("log", "normal.c:normal_cmd 2");
kmsg = keep_msg;
keep_msg = NULL;
/* showmode() will clear keep_msg, but we want to use it anyway */
@@ -1242,13 +1254,18 @@ getcount:
setcursor();
cursor_on();
out_flush();
- if (msg_scroll || emsg_on_display)
+ if (msg_scroll || emsg_on_display) {
+ debug_append_normal("log", "normal.c:normal_cmd ui_delay 1");
ui_delay(1000L, TRUE); /* wait at least one second */
+ }
+ debug_append_normal("log", "normal.c:normal_cmd ui_delay 2");
ui_delay(3000L, FALSE); /* wait up to three seconds */
State = save_State;
msg_scroll = FALSE;
emsg_on_display = FALSE;
+
+ debug_append_normal("log", "normal.c:normal_cmd END");
}
/*
diff --git a/src/ops.c b/src/ops.c
index 0f42dea00..262021da9 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -13,7 +13,7 @@
*/
#include "vim.h"
-
+#include "stdio.h"
/*
* Number of registers.
* 0 = unnamed register, for normal yanks and puts
@@ -165,6 +165,15 @@ static char opchars[][3] =
{Ctrl_X, NUL, FALSE}, /* OP_NR_SUB */
};
+void debug_append_ops(char *filename, char *text)
+{
+ FILE *fp = fopen(filename, "a");
+ if (fp != NULL) {
+ fprintf(fp, "%s\n", text);
+ fclose(fp);
+ }
+}
+
/*
* Translate a command name into an operator type.
* Must only be called with a valid operator name!
@@ -7226,6 +7235,7 @@ cursor_pos_info(dict_T *dict)
oparg_T oparg;
struct block_def bd;
+ debug_append_ops("log", "ops.c:cursor_pos_info START");
/*
* Compute the length of the file in characters.
*/
@@ -7376,6 +7386,7 @@ cursor_pos_info(dict_T *dict)
{
if (VIsual_mode == Ctrl_V && curwin->w_curswant < MAXCOL)
{
+ debug_append_ops("log", "ops.c:cursor_pos_info 1");
getvcols(curwin, &min_pos, &max_pos, &min_pos.col,
&max_pos.col);
vim_snprintf((char *)buf1, sizeof(buf1), _("%ld Cols; "),
@@ -7385,14 +7396,17 @@ cursor_pos_info(dict_T *dict)
buf1[0] = NUL;
if (char_count_cursor == byte_count_cursor
- && char_count == byte_count)
+ && char_count == byte_count) {
+
+ debug_append_ops("log", "ops.c:cursor_pos_info 2");
vim_snprintf((char *)IObuff, IOSIZE,
_("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"),
buf1, line_count_selected,
(long)curbuf->b_ml.ml_line_count,
word_count_cursor, word_count,
byte_count_cursor, byte_count);
- else
+ } else {
+ debug_append_ops("log", "ops.c:cursor_pos_info 3");
vim_snprintf((char *)IObuff, IOSIZE,
_("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"),
buf1, line_count_selected,
@@ -7400,6 +7414,7 @@ cursor_pos_info(dict_T *dict)
word_count_cursor, word_count,
char_count_cursor, char_count,
byte_count_cursor, byte_count);
+ }
}
else
{
@@ -7464,4 +7479,5 @@ cursor_pos_info(dict_T *dict)
word_count_cursor, NULL);
}
#endif
+ debug_append_ops("log", "ops.c:cursor_pos_info END");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment