@hncode/hncode 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/tools/edit.js CHANGED
@@ -61,7 +61,20 @@ Omitting new_string entirely is an error — pass "" to delete.
61
61
  AFTER A SUCCESSFUL EDIT, the result quotes the file around what you wrote — five lines either side, in the same
62
62
  numbered form Read uses. So editing a region you have just edited does NOT need another Read of it: the previous
63
63
  Edit already shows you those lines as they are on disk now. Read again when you need a part of the file the edit
64
- did not show, or when a different tool or the user has changed the file since.`,
64
+ did not show, or when a different tool or the user has changed the file since.
65
+
66
+ LINE NUMBERS GO STALE THE MOMENT YOU EDIT. Every edit shifts the lines below it, so the numbers you read
67
+ a moment ago are wrong for the next one. Read the file again before the NEXT edit, or work from the lines
68
+ the previous edit printed — those are current.
69
+
70
+ THE FAILURE THIS PREVENTS: an edit whose range was off by a line or two wrote the neighbouring line a second
71
+ time, because the range covered a line the replacement did not. The file then held a duplicate, the
72
+ duplicate looked like damage, and the fix restated another neighbour — the duplicates multiplied until the
73
+ file was unusable. The cause is almost never the content; it is a range that no longer matched the file.
74
+
75
+ SO: one edit at a time. Make ONE change, look at the result, then make the next. Several edits in a row
76
+ without a Read in between are several chances to act on stale line numbers. And if an edit produced a
77
+ duplicate, the fix is to remove the duplicated line — never to restate another one.`,
65
78
  parameters: {
66
79
  type: 'object',
67
80
  properties: {