Created
May 15, 2016 13:13
-
-
Save mscalora/86f3862a5f3aa4af2ac4e3ddcef9b305 to your computer and use it in GitHub Desktop.
Add extra nano undo debug logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/winio.c | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/winio.c (date 1462931713000) | |
+++ src/winio.c (revision ) | |
@@ -3076,6 +3076,12 @@ | |
(long)openfile->filebot->lineno, linepct, | |
(unsigned long)cur_xpt, (unsigned long)cur_lenpt, colpct, | |
(unsigned long)i, (unsigned long)openfile->totsize, charpct); | |
+ | |
+#ifdef DEBUG | |
+ /* dump the undo stack to stderr every time the stats feature is invoked * | |
+ * debug build only */ | |
+ debug_display_undo_stack(); | |
+#endif | |
} | |
/* Unconditionally display the current cursor position. */ | |
Index: src/proto.h | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/proto.h (date 1462931713000) | |
+++ src/proto.h (revision ) | |
@@ -754,6 +754,9 @@ | |
void update_comment_undo(ssize_t lineno); | |
bool comment_line(bool add_comment, filestruct *f, const char *comment_seq); | |
#endif | |
+#ifdef DEBUG | |
+void debug_display_undo_stack(); | |
+#endif | |
#endif | |
size_t get_totsize(const filestruct *begin, const filestruct *end); | |
filestruct *fsfromline(ssize_t lineno); | |
Index: src/text.c | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- src/text.c (date 1462931713000) | |
+++ src/text.c (revision ) | |
@@ -1239,6 +1239,53 @@ | |
openfile->last_action = action; | |
} | |
+#ifdef DEBUG | |
+void debug_display_undo_stack() { | |
+ static const char *UNDOSTR[] = { | |
+ "ADD", "DEL", "BACK", "CUT", "CUT_EOF", "REPLACE", | |
+#ifndef DISABLE_WRAPPING | |
+ "SPLIT_BEGIN", "SPLIT_END", | |
+#endif | |
+#ifndef DISABLE_COMMENT | |
+ "COMMENT", "UNCOMMENT", | |
+#endif | |
+ "JOIN", "PASTE", "INSERT", "ENTER", "OTHER" | |
+ }; | |
+ int i = 1; | |
+ undo *u = openfile->undotop; | |
+ fprintf(stderr, "\n"); | |
+ if (!u) | |
+ fprintf(stderr, "UNDO: none\n"); | |
+ while(u) { | |
+ if (u==openfile->current_undo) | |
+ fprintf(stderr, "UNDO: ---- TOP -- undo: v redo: %s ------\n", (i>1 ? "^" : "none")); | |
+ fprintf(stderr, "UNDO %2d: %s at %d with %d:%s%.70s%s\n", | |
+ i, | |
+ UNDOSTR[(int)u->type], | |
+ (int)u->lineno, | |
+ (int)u->begin, | |
+ u->strdata ? "\"" : "", | |
+ u->strdata ? u->strdata : "NULL", | |
+ u->strdata ? "\"" : "" | |
+ ); | |
+ undo_group *grouping = u->grouping; | |
+ while(grouping) { | |
+ fprintf(stderr, " %ld to %ld\n", grouping->top_line, grouping->bottom_line); | |
+ grouping = grouping->next; | |
+ } | |
+ i++; | |
+ u = u->next; | |
+ if (i>=50) { | |
+ i = -1; | |
+ fprintf(stderr, "UNDO: -- more items not shown --\n"); | |
+ break; | |
+ } | |
+ } | |
+ if (i>1 && 0==openfile->current_undo) | |
+ fprintf(stderr, "UNDO: ---- TOP -- undo: none redo: ^ ------\n"); | |
+} | |
+#endif | |
+ | |
#ifndef DISABLE_COMMENT | |
/* Add a comment undo action. This should be called once for each use | |
* of the comment or uncomment feature that modifies the document. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment