Skip to content

Commit a0681b6

Browse files
jderegclaude
andcommitted
Fix getLastSnippet() to return bounded 200-char context
Previously returned 0 to 8192 characters depending on buffer position. Now consistently returns up to the last 200 characters read, providing useful error context without excessive output. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 87e7db8 commit a0681b6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/com/cedarsoftware/util/FastReader.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,14 @@ public int getCol() {
178178
return 0;
179179
}
180180

181+
/**
182+
* Returns the last portion of the buffer that has been read, useful for error context.
183+
* @return up to the last 200 characters read from the current buffer
184+
*/
181185
public String getLastSnippet() {
182-
return new String(buf, 0, position);
186+
int snippetLength = Math.min(position, 200);
187+
int start = position - snippetLength;
188+
return new String(buf, start, snippetLength);
183189
}
184190

185191
}

0 commit comments

Comments
 (0)