Changesets · Branches · Tags · Compare
| Changeset | 9da59f739c22a0d74ac4ee6ef2101c7a5031a42be7be4ddc0b4e67b48821b9fe |
|---|---|
| Author | Jacob Kim <jacob@continue.dev> · 2025-07-02 15:37 -07:00 |
| Committer | Jacob Kim <jacob@continue.dev> · 2025-07-02 15:37 -07:00 |
| Parents | bf84192738a3 |
1 file changed
modified core/nextEdit/diff/diff.ts +18 −11
| @@ -125,10 +125,15 @@ | ||
| 125 | 125 | oldEditRange: string, |
| 126 | 126 | newEditRange: string, |
| 127 | 127 | cursorPosition: { line: number; character: number }, |
| 128 | -): { | |
| 129 | - isFim: boolean; | |
| 130 | - fimText: string; | |
| 131 | -} { | |
| 128 | +): | |
| 129 | + | { | |
| 130 | + isFim: true; | |
| 131 | + fimText: string; | |
| 132 | + } | |
| 133 | + | { | |
| 134 | + isFim: false; | |
| 135 | + fimText: null; | |
| 136 | + } { | |
| 132 | 137 | // Find the common prefix. |
| 133 | 138 | let prefixLength = 0; |
| 134 | 139 | while ( |
| @@ -177,11 +182,13 @@ | ||
| 177 | 182 | // Check if the old text is completely preserved (no deletion). |
| 178 | 183 | const noTextDeleted = suffixStartInOld - prefixLength <= 0; |
| 179 | 184 | |
| 180 | - // Extract the content between prefix and suffix in the new string. | |
| 181 | - const fimText = newEditRange.substring(prefixLength, suffixStartInNew); | |
| 182 | - | |
| 183 | - return { | |
| 184 | - isFim: cursorBetweenPrefixAndSuffix && noTextDeleted, | |
| 185 | - fimText, | |
| 186 | - }; | |
| 185 | + const isFim = cursorBetweenPrefixAndSuffix && noTextDeleted; | |
| 186 | + | |
| 187 | + if (isFim) { | |
| 188 | + // Extract the content between prefix and suffix in the new string. | |
| 189 | + const fimText = newEditRange.substring(prefixLength, suffixStartInNew); | |
| 190 | + return { isFim, fimText }; | |
| 191 | + } else { | |
| 192 | + return { isFim, fimText: null }; | |
| 193 | + } | |
| 187 | 194 | } |