Commit bcde80a
authored
feat: add option to control behavior when rejecting new file diffs (#114)
# Add option to control behavior when rejecting new file diffs
This PR adds a new configuration option `on_new_file_reject` that controls what happens when a user rejects a diff for a new file:
- `keep_empty` (default): Leaves the empty buffer in place
- `close_window`: Closes the placeholder split window
Previously, when rejecting a new file diff, the plugin would always try to delete the original buffer. This could cause issues when the buffer was reused from an existing empty buffer, leading to potential crashes when attempting to reopen a diff.
The PR includes:
- New configuration option in `config.lua` with validation
- Type definition in `types.lua`
- Logic in `diff.lua` to track whether the original buffer was created by the plugin
- Only delete the original buffer on reject if it was created by the plugin
- Unit test to verify the fix works correctly
This change improves stability when working with new files and gives users more control over the UI behavior.1 parent 678a582 commit bcde80a
File tree
4 files changed
+127
-3
lines changed- lua/claudecode
- tests/unit
4 files changed
+127
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
| 895 | + | |
| 896 | + | |
895 | 897 | | |
896 | 898 | | |
897 | | - | |
898 | 899 | | |
899 | 900 | | |
900 | 901 | | |
| |||
929 | 930 | | |
930 | 931 | | |
931 | 932 | | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
932 | 939 | | |
933 | 940 | | |
| 941 | + | |
934 | 942 | | |
935 | 943 | | |
936 | 944 | | |
| |||
945 | 953 | | |
946 | 954 | | |
947 | 955 | | |
| 956 | + | |
948 | 957 | | |
949 | 958 | | |
950 | 959 | | |
| |||
1030 | 1039 | | |
1031 | 1040 | | |
1032 | 1041 | | |
1033 | | - | |
1034 | | - | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1035 | 1049 | | |
1036 | 1050 | | |
1037 | 1051 | | |
| |||
1177 | 1191 | | |
1178 | 1192 | | |
1179 | 1193 | | |
| 1194 | + | |
1180 | 1195 | | |
1181 | 1196 | | |
1182 | 1197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
0 commit comments