id stringlengths 20 30 | source stringclasses 1
value | chunk_index int64 0 520k | token_count int32 154 512 | content stringlengths 185 57.5k |
|---|---|---|---|---|
rust_dataset_chunk_508600 | rust_dataset.txt | 508,600 | 512 | _with('\n') && new_span.ends_with('\n') {
new_span.pop();
}
let mut result = String::new();
result.push_str(&old_editable[..start_byte]);
result.push_str(&new_span);
result.push_str(&old_editable[end_byte..]);
Ok(result)
}
/// Compare old and new editable text, find the minimal marker... |
rust_dataset_chunk_508601 | rust_dataset.txt | 508,601 | 512 | bounded..]);
} else {
result.push_str(new_span);
}
} else {
result.push_str(new_span);
}
if !result.ends_with('\n') {
result.push('\n');
}
result.push_str(&marker_tag(end_marker_num));
result.push('\n');
result.push_str(end_marker);
Ok(result... |
rust_dataset_chunk_508602 | rust_dataset.txt | 508,602 | 512 | search_from = 0;
while let Some(rel_pos) = text[search_from..].find(prefix) {
let tag_start = search_from + rel_pos;
let payload_start = tag_start + prefix.len();
if let Some(suffix_rel) = text[payload_start..].find(MARKER_TAG_SUFFIX) {
let payload_end = payload_start + suffix_r... |
rust_dataset_chunk_508603 | rust_dataset.txt | 508,603 | 512 | .iter()
.rev()
.zip(b[b.len() - max_suffix..].iter().rev())
.take_while(|(x, y)| x == y)
.count();
(prefix, suffix)
}
/// Map a byte offset from old span coordinates to new span coordinates,
/// using common prefix/suffix within the span for accuracy.
fn map_boundary_offset(... |
rust_dataset_chunk_508604 | rust_dataset.txt | 508,604 | 512 | _text: &str,
cursor_offset_in_editable: usize,
cursor_marker: &str,
marker_offsets: &[usize],
tag_for_index: impl Fn(usize) -> String,
) {
let mut cursor_placed = false;
for (i, &offset) in marker_offsets.iter().enumerate() {
output.push_str(&tag_for_index(i));
if let Some(&next... |
rust_dataset_chunk_508605 | rust_dataset.txt | 508,605 | 512 | _marker,
&marker_offsets,
|i| marker_tag(i + 1),
);
}
/// Parse byte-exact model output and reconstruct the full new editable region.
///
/// `resolve_boundary` maps a parsed tag value to an absolute byte offset in
/// old_editable, given the marker_offsets. Returns `(start_byte, end_byte)` or
/// ... |
rust_dataset_chunk_508606 | rust_dataset.txt | 508,606 | 512 | let actual: Vec<isize> = tags.iter().map(|t| t.value).collect();
if actual != expected {
eprintln!(
"V0316 marker sequence validation failed: expected {:?}, got {:?}. Attempting best-effort parse.",
expected, actual
);
}
... |
rust_dataset_chunk_508607 | rust_dataset.txt | 508,607 | 512 | output: &str) -> Result<String> {
let tags = collect_marker_tags(output);
if tags.len() >= 2 {
let start_num = tags[0].value;
let end_num = tags[tags.len() - 1].value;
if start_num != end_num {
let expected: Vec<isize> = (start_num..=end_num).collect();
let actu... |
rust_dataset_chunk_508608 | rust_dataset.txt | 508,608 | 512 | _editable.as_bytes(), new_editable.as_bytes());
let change_end_in_old = old_editable.len() - common_suffix;
let mut start_marker_idx = marker_offsets
.iter()
.rposition(|&offset| offset <= common_prefix)
.unwrap_or(0);
let mut end_marker_idx = marker_offsets
.iter()
... |
rust_dataset_chunk_508609 | rust_dataset.txt | 508,609 | 512 | _placed = true;
let cursor_in_block = cursor_offset - abs_start;
let bounded = cursor_in_block.min(block_content.len());
result.push_str(&block_content[..bounded]);
result.push_str(cursor_marker);
result.push_str(&block_... |
rust_dataset_chunk_508610 | rust_dataset.txt | 508,610 | 512 | _in_new, &marker_offsets));
encode_from_old_and_new_impl(
old_editable,
new_editable,
cursor_offset_in_new,
cursor_marker,
end_marker,
&no_edit_tag,
&marker_offsets,
|block_idx| marker_tag(block_idx + 1),
)
}
#[cfg(test)]
mod tests {
use super... |
rust_dataset_chunk_508611 | rust_dataset.txt | 508,611 | 512 | _split_skips_closer_line() {
let text = "\
impl Plugin for AhoySchedulePlugin {
fn build(&self, app: &mut App) {
app.configure_sets(
self.schedule,
(
AhoySystems::MoveCharacters,
AhoySystems::ApplyForcesToDynamicRigidBodies,
)
... |
rust_dataset_chunk_508612 | rust_dataset.txt | 508,612 | 512 | 7\na8\n}\n}\n}\n}\n}\ncase 'x': {\nbody\n";
let offsets = compute_marker_offsets(text);
let case_start = text.find("case 'x': {").expect("case line exists");
assert!(
!offsets.contains(&case_start),
"boundary should not nudge beyond max forward lines; offsets: {offsets:?... |
rust_dataset_chunk_508613 | rust_dataset.txt | 508,613 | 512 | () > 2,
"expected interior markers: {marker_offsets:?}"
);
assert!(marker_offsets.contains(&relative_start));
assert!(marker_offsets.contains(&relative_end));
assert!(editable_range.start <= cursor_offset);
assert!(editable_range.end >= cursor_offset);
assert!... |
rust_dataset_chunk_508614 | rust_dataset.txt | 508,614 | 512 | : {line_count} lines in block {block:?} with offsets {offsets:?}"
);
}
}
#[test]
fn test_extract_marker_span() {
let text = "<|marker_2|>\n new content\n<|marker_3|>\n";
let (start, end, content) = extract_marker_span(text).unwrap();
assert_eq!(start, 2);
... |
rust_dataset_chunk_508615 | rust_dataset.txt | 508,615 | 512 | ,
"<|user_cursor|>",
">>>>>>> UPDATED\n",
"NO_EDITS\n",
)
.unwrap();
assert!(result.contains("<|marker_1|>"));
assert!(result.contains("<|marker_2|>"));
assert!(result.contains("aaa\nBBB\nccc\n"));
assert!(result.ends_with(">>>>>>> UPDA... |
rust_dataset_chunk_508616 | rust_dataset.txt | 508,616 | 512 | result}");
assert!(result.contains("B<|user_cursor|>BB"), "result: {result}");
}
#[test]
fn test_extract_marker_span_strips_intermediate_markers() {
let text = "<|marker_2|>\nline1\n<|marker_3|>\nline2\n<|marker_4|>";
let (start, end, content) = extract_marker_span(text).unwrap();
... |
rust_dataset_chunk_508617 | rust_dataset.txt | 508,617 | 512 | .replace("<|user_cursor|>", "");
let stripped = strip_marker_tags(&stripped);
assert_eq!(stripped, editable);
}
#[test]
fn test_apply_marker_span_v0316_basic() {
let old = "aaa\nbbb\nccc\n";
let output = "<|marker_1|>aaa\nBBB\nccc\n<|marker_2|>";
let result = apply_m... |
rust_dataset_chunk_508618 | rust_dataset.txt | 508,618 | 512 | , &output).unwrap();
assert_eq!(result, new_content);
}
#[test]
fn test_apply_marker_span_v0316_byte_exact_no_normalization() {
let old = "aaa\nbbb\nccc\n";
let output = "<|marker_1|>aaa\nBBB\nccc<|marker_2|>";
let result = apply_marker_span_v0316(old, output).unwrap();
... |
rust_dataset_chunk_508619 | rust_dataset.txt | 508,619 | 512 | () {
let old = "aaa\nbbb\nccc\n";
let new = "aaa\nBBB\nccc\n";
let result =
encode_from_old_and_new_v0316(old, new, Some(5), "<|user_cursor|>", "<|end|>").unwrap();
assert!(result.contains("<|user_cursor|>"), "result: {result}");
assert!(result.contains("B<|user_curso... |
rust_dataset_chunk_508620 | rust_dataset.txt | 508,620 | 512 | 7_includes_relative_markers_and_cursor() {
let editable = "aaa\nbbb\nccc\n";
let mut output = String::new();
write_editable_with_markers_v0317(&mut output, editable, 4, "<|user_cursor|>");
assert!(output.contains("<|marker-0|>"));
assert!(output.contains("<|user_cursor|>"));
... |
rust_dataset_chunk_508621 | rust_dataset.txt | 508,621 | 512 | |>", "<|end|>").unwrap();
let stripped = encoded
.strip_suffix("<|end|>")
.expect("should have end marker");
let stripped = stripped.replace("<|user_cursor|>", "");
let reconstructed = apply_marker_span_v0317(old, &stripped, cursor).unwrap();
assert_eq!(reconstruc... |
rust_dataset_chunk_508622 | rust_dataset.txt | 508,622 | 512 | _marker_span_v0318(old, stripped).unwrap();
assert_eq!(reconstructed, new);
}
#[test]
fn test_roundtrip_v0318_append_at_end_of_editable_region() {
let old = "line1\nline2\nline3\n";
let new = "line1\nline2\nline3\nline4\n";
let encoded =
encode_from_old_and_new_v... |
rust_dataset_chunk_508623 | rust_dataset.txt | 508,623 | 512 | load) {
\t\t\t\tcase '':
\t\t\t\tcase 'true':
\t\t\t\tcase 'hover': {
\t\t\t\t\tlink.addEventListener('mouseenter', function callback() {
\t\t\t\t\t\tlink.removeEventListener('mouseenter', callback);
\t\t\t\t\t\tanchorPreload(link);
\t\t\t\t\t});
";
let new = old.replacen(
"\t\t\t\tcase 'true':\n",
... |
rust_dataset_chunk_508624 | rust_dataset.txt | 508,624 | 512 | );
}
let mut result = String::with_capacity(diff.len());
for line in diff.lines() {
match DiffLine::parse(line) {
DiffLine::OldPath { path } => {
let stripped = path
.strip_prefix(&prefix_with_slash)
.unwrap_or(path.as_ref());
... |
rust_dataset_chunk_508625 | rust_dataset.txt | 508,625 | 512 | Addition(content) => {
let clean_content = content.replace(INLINE_CURSOR_MARKER, "");
if cursor_offset.is_none()
&& let Some(marker_offset) = content.find(INLINE_CURSOR_MARKER)
{
cursor_offset = Some(line_start_offset + marker_offse... |
rust_dataset_chunk_508626 | rust_dataset.txt | 508,626 | 512 | touched_phantom = edit.range.end > new_len;
edit.range.start = edit.range.start.min(new_len);
edit.range.end = edit.range.end.min(new_len);
if touched_phantom {
// The replacement text was also written with a
//... |
rust_dataset_chunk_508627 | rust_dataset.txt | 508,627 | 512 | unk_start: u32,
after_hunk_start: u32,
before_hunk_len: u32,
after_hunk_len: u32,
old_line_offset: u32,
new_line_offset: u32,
context_lines: u32,
buffer: String,
dst: String,
}
impl<'a> OffsetUnifiedDiffBuilder<'a> {
fn new(
input: &'a InternedInput<&'a str>,
old_lin... |
rust_dataset_chunk_508628 | rust_dataset.txt | 508,628 | 512 | unk_len += len;
self.pos = move_to;
}
}
impl OffsetUnifiedDiffBuilder<'_> {
fn process_change(&mut self, before: Range<u32>, after: Range<u32>) {
if before.start - self.pos > self.context_lines * 2 {
self.flush();
}
if self.before_hunk_len == 0 && self.after_hunk_len... |
rust_dataset_chunk_508629 | rust_dataset.txt | 508,629 | 512 | n') {
result.push('\n');
}
result
}
pub fn apply_diff_to_string(diff_str: &str, text: &str) -> Result<String> {
apply_diff_to_string_with_hunk_offset(diff_str, text).map(|(text, _)| text)
}
/// Applies a diff to a string and returns the result along with the offset where
/// the first hunk's cont... |
rust_dataset_chunk_508630 | rust_dataset.txt | 508,630 | 512 | }
}
Ok((text, first_hunk_offset))
}
struct PatchFile<'a> {
old_path: Cow<'a, str>,
new_path: Cow<'a, str>,
}
pub struct DiffParser<'a> {
current_file: Option<PatchFile<'a>>,
current_line: Option<(&'a str, DiffLine<'a>)>,
hunk: Hunk,
diff: std::str::Lines<'a>,
pending_start... |
rust_dataset_chunk_508631 | rust_dataset.txt | 508,631 | 512 | None => (true, true),
Some(DiffLine::HunkHeader(_)) => (true, false),
_ => (false, false),
};
if hunk_done {
if let Some(file) = &self.current_file
&& !self.hunk.is_empty()
{
let status = if... |
rust_dataset_chunk_508632 | rust_dataset.txt | 508,632 | 512 | self.hunk.context.len() + del.len() + '\n'.len_utf8();
if let Some(last_edit) = self.hunk.edits.last_mut()
&& last_edit.range.end == range.start
{
last_edit.range.end = range.end;
... |
rust_dataset_chunk_508633 | rust_dataset.txt | 508,633 | 512 | Cow<'a, str> },
NewPath { path: Cow<'a, str> },
HunkHeader(Option<HunkLocation>),
Context(&'a str),
Deletion(&'a str),
Addition(&'a str),
NoNewlineAtEOF,
Garbage(&'a str),
}
#[derive(Debug, PartialEq)]
pub struct HunkLocation {
pub start_line_old: u32,
pub count_old: u32,
pub s... |
rust_dataset_chunk_508634 | rust_dataset.txt | 508,634 | 512 | ::Deletion(deleted_header))
} else if line.is_empty() {
Some(Self::Context(""))
} else if let Some(context) = line.strip_prefix(" ") {
Some(Self::Context(context))
} else {
Some(Self::Addition(line.strip_prefix("+")?))
}
}
}
impl<'a> Display for D... |
rust_dataset_chunk_508635 | rust_dataset.txt | 508,635 | 512 | .is_ascii_whitespace() && !in_quote {
break;
} else {
path.push(char);
}
if let Some(prefix) = strip_prefix
&& path == prefix
{
strip_prefix.take();
path.clear();
}
}
Cow::Owned(path)
}
fn eat_required_whitesp... |
rust_dataset_chunk_508636 | rust_dataset.txt | 508,636 | 512 | DiffLine::OldPath {
path: "file".into()
},
"{option}",
);
}
}
#[test]
fn hunk_header_extra_space() {
let options = [
"@@ -1,2 +1,3 @@",
"@@ -1,2 +1,3 @@",
"@@\t-1,2\t+1,3\t@@",
... |
rust_dataset_chunk_508637 | rust_dataset.txt | 508,637 | 512 | /bar/baz quox.txt\""),
"foo/bar/baz quox.txt"
);
assert_eq!(
parse_header_path("a/", "\"foo/bar/baz quox.txt\""),
"foo/bar/baz quox.txt"
);
assert_eq!(parse_header_path("a/", "\"whatever 🤷\""), "whatever 🤷");
assert_eq!(
parse_hea... |
rust_dataset_chunk_508638 | rust_dataset.txt | 508,638 | 512 | .py
+++ b/file.py
@@ -55,7 +55,3 @@ class CustomDataset(Dataset):
torch.set_rng_state(state)
mask = self.transform(mask)
- if self.mode == 'Training':
- return (img, mask, name)
- else... |
rust_dataset_chunk_508639 | rust_dataset.txt | 508,639 | 512 | 1,2 -> line 0 (0-indexed)
},
status: FileStatus::Modified,
},
DiffEvent::FileEnd { renamed_to: None }
],
);
}
#[test]
fn test_double_no_newline_at_eof() {
// Two consecutive "no newline" markers - the second... |
rust_dataset_chunk_508640 | rust_dataset.txt | 508,640 | 512 | old\nline3\nline4".into(),
edits: vec![Edit {
range: 6..10, // "old\n" is 4 bytes
text: "new\n".into() // Still has newline
}],
start_line: Some(0),
},
... |
rust_dataset_chunk_508641 | rust_dataset.txt | 508,641 | 512 | _diff_to_string(diff, text).unwrap();
assert_eq!(result, "line1\nreplaced\nline3\n");
}
#[test]
fn test_apply_diff_to_string_deletion_at_end_no_trailing_newline() {
// Deletion of the last line when text has no trailing newline.
// The edit range must be clamped so it doesn't index ... |
rust_dataset_chunk_508642 | rust_dataset.txt | 508,642 | 512 | 3 +1,2 @@
first
-remove first
first
@@ -4,3 +3,2 @@
same
-remove
same
"};
let result = apply_diff_to_string(diff, text).unwrap();
assert_eq!(result, "first\nfirst\nsame\nsame\nsame\nremove\nsame\n");
}
... |
rust_dataset_chunk_508643 | rust_dataset.txt | 508,643 | 512 | a
// second, spurious candidate.
let text = "aaa\nbbb\nccc";
let mut hunk = Hunk {
context: "bbb\nccc\n".into(),
edits: vec![],
start_line: None,
};
let candidates = find_context_candidates(text, &mut hunk);
// No exact match (text en... |
rust_dataset_chunk_508644 | rust_dataset.txt | 508,644 | 512 | 8\n"
);
let diff_no_context = unified_diff_with_context(old_text, new_text, 0, 0, 0);
assert_eq!(diff_no_context, "@@ -6,1 +6,1 @@\n-CHANGE_ME\n+CHANGED\n");
}
}
--- FILE: zed/crates/zeta_prompt/src/zeta_prompt.rs ---
pub mod excerpt_ranges;
pub mod hashed_regions;
pub mod multi_region;
p... |
rust_dataset_chunk_508645 | rust_dataset.txt | 508,645 | 512 | related_files: Option<Vec<RelatedFile>>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub active_buffer_diagnostics: Vec<ActiveBufferDiagnostic>,
/// These ranges let the server select model-appropriate subsets.
pub excerpt_ranges: ExcerptRanges,
/// Byte offset ranges within `cursor_ex... |
rust_dataset_chunk_508646 | rust_dataset.txt | 508,646 | 512 | V0211SeedCoder,
V0331SeedCoderModelPy,
v0226Hashline,
V0304VariableEdit,
V0304SeedNoEdits,
/// Multi-block marker spans with NO_EDITS sentinel.
V0306SeedMultiRegions,
/// Byte-exact marker spans; all intermediate markers emitted; repeated marker means no-edit.
V0316SeedMultiRegions,
... |
rust_dataset_chunk_508647 | rust_dataset.txt | 508,647 | 512 | bail!(
"`{format_name}` matched more than one of:\n{}",
Self::options_as_string()
);
}
Ok(result)
}
pub fn options_as_string() -> String {
ZetaFormat::iter()
.map(|format| format!("- {}\n", <&'static str>::from(format)))
... |
rust_dataset_chunk_508648 | rust_dataset.txt | 508,648 | 512 | : u32,
pub excerpts: Vec<RelatedExcerpt>,
#[serde(default)]
pub in_open_source_repo: bool,
}
#[derive(Clone, Debug, PartialEq, Hash, Serialize, Deserialize)]
pub struct RelatedExcerpt {
pub row_range: Range<u32>,
pub text: Arc<str>,
#[serde(default)]
pub order: usize,
#[serde(default)]
... |
rust_dataset_chunk_508649 | rust_dataset.txt | 508,649 | 512 | _with_budget(
format,
input.cursor_path.as_ref(),
context,
&editable_range,
cursor_offset,
&input.events,
&related_files,
&input.active_buffer_diagnostics,
Some(input.cursor_position.row),
max_prompt_tokens_for_format(format),
)
}
fn m... |
rust_dataset_chunk_508650 | rust_dataset.txt | 508,650 | 512 | ;
let text = excerpt.text.as_ref();
let mut row_start = 0;
for row in 0..=relative_row {
if row == relative_row {
let row_end = text[row_start..]
.find('\n')
.map_or(text.len(), |offset| row_start + offset);
let row_text = &text[row_start..row... |
rust_dataset_chunk_508651 | rust_dataset.txt | 508,651 | 512 | 0211Prefill => v0211_prefill::special_tokens(),
ZetaFormat::V0211SeedCoder | ZetaFormat::V0331SeedCoderModelPy => {
seed_coder::special_tokens()
}
ZetaFormat::v0226Hashline => hashline::special_tokens(),
ZetaFormat::V0304VariableEdit => v0304_variable_edit::special_tokens(),
... |
rust_dataset_chunk_508652 | rust_dataset.txt | 508,652 | 512 | seed_coder::FIM_PREFIX,
seed_coder::FIM_MIDDLE,
seed_coder::FILE_MARKER,
hashed_regions::V0615_END_MARKER,
CURSOR_MARKER,
hashed_regions::MARKER_TAG_PREFIX,
];
TOKENS
}
ZetaFormat::V0327SingleFile =>... |
rust_dataset_chunk_508653 | rust_dataset.txt | 508,653 | 512 | Format::V0304SeedNoEdits => (350, 150),
ZetaFormat::V0615HashRegions => (8000, 0),
ZetaFormat::V0304VariableEdit => (1024, 0),
}
}
pub fn stop_tokens_for_format(format: ZetaFormat) -> &'static [&'static str] {
match format {
ZetaFormat::v0226Hashline => &[hashline::NO_EDITS_COMMAND_MAR... |
rust_dataset_chunk_508654 | rust_dataset.txt | 508,654 | 512 | a format.
///
/// This match is intentionally exhaustive with no wildcard arm so that adding a
/// new [`ZetaFormat`] fails to compile until its delimiters are specified.
pub fn training_delimiters_for_format(format: ZetaFormat) -> TrainingDelimiters {
match format {
ZetaFormat::V0211SeedCoder
| Ze... |
rust_dataset_chunk_508655 | rust_dataset.txt | 508,655 | 512 | (
format: ZetaFormat,
ranges: &ExcerptRanges,
) -> (Range<usize>, Range<usize>) {
match format {
ZetaFormat::V0112MiddleAtEnd | ZetaFormat::V0113Ordered => (
ranges.editable_150.clone(),
ranges.editable_150_context_350.clone(),
),
ZetaFormat::V0114180EditableR... |
rust_dataset_chunk_508656 | rust_dataset.txt | 508,656 | 512 | write_cursor_excerpt_section_for_format(
format: ZetaFormat,
prompt: &mut String,
path: &Path,
context: &str,
editable_range: &Range<usize>,
cursor_offset: usize,
) {
match format {
ZetaFormat::V0112MiddleAtEnd => v0112_middle_at_end::write_cursor_excerpt_section(
prompt... |
rust_dataset_chunk_508657 | rust_dataset.txt | 508,657 | 512 | path,
context,
editable_range,
cursor_offset,
seed_coder::FILE_MARKER,
));
}
ZetaFormat::V0608QwenMultiRegions => {
prompt.push_str(&build_v0318_cursor_prefix(
path,
co... |
rust_dataset_chunk_508658 | rust_dataset.txt | 508,658 | 512 | _in_editable = cursor_offset - editable_range.start;
multi_region::write_editable_with_markers_v0316(
&mut section,
editable_text,
cursor_in_editable,
CURSOR_MARKER,
);
if !section.ends_with('\n') {
section.push('\n');
}
section
}
fn build_v0318_cursor_prefi... |
rust_dataset_chunk_508659 | rust_dataset.txt | 508,659 | 512 | section.push_str(&context[..editable_range.start]);
let editable_text = &context[editable_range.clone()];
let cursor_in_editable = cursor_offset - editable_range.start;
multi_region::write_editable_with_markers_v0317(
&mut section,
editable_text,
cursor_in_editable,
CURS... |
rust_dataset_chunk_508660 | rust_dataset.txt | 508,660 | 512 | _files = input.related_files.as_deref()?;
struct RenderedExcerpt {
file_ix: usize,
excerpt_ix: usize,
order: usize,
rendered: String,
}
let mut candidates = Vec::new();
let mut required_candidate_ix = None;
for (file_ix, file) in related_files.iter().enumerate() {
... |
rust_dataset_chunk_508661 | rust_dataset.txt | 508,661 | 512 | let mut selection_order: Vec<usize> = (0..candidates.len()).collect();
selection_order.sort_by_key(|&candidate_ix| {
let candidate = &candidates[candidate_ix];
(candidate.order, candidate.file_ix, candidate.excerpt_ix)
});
for candidate_ix in selection_order {
if included[candidate... |
rust_dataset_chunk_508662 | rust_dataset.txt | 508,662 | 512 | ".len()
+ seed_coder::FIM_PREFIX.len()
+ seed_coder::FIM_MIDDLE.len(),
);
let related_files_budget = max_tokens.saturating_sub(fixed_tokens);
let related_files_section = format_hash_region_related_files_within_budget(
input,
&marker_table,
&cursor,
rel... |
rust_dataset_chunk_508663 | rust_dataset.txt | 508,663 | 512 | cursor_offset,
&input.events,
&filtered_related_files,
&input.active_buffer_diagnostics,
cursor_buffer_row,
max_tokens,
)
}
fn format_resolved_prompt_with_budget(
format: ZetaFormat,
path: &Path,
context: &str,
editable_range: &Range<usize>,
cursor_offse... |
rust_dataset_chunk_508664 | rust_dataset.txt | 508,664 | 512 | );
assemble_single_file_fim_prompt(
context,
editable_range,
&cursor_section,
events,
apply_prompt_budget_margin(max_tokens),
)
}
_ => {
let mut cursor_section = String::new()... |
rust_dataset_chunk_508665 | rust_dataset.txt | 508,665 | 512 | _indices.truncate(MAX_DIAGNOSTICS);
}
diagnostic_indices.sort_unstable_by_key(&distance);
}
let mut output = format!("{}diagnostics\n", seed_coder::FILE_MARKER);
let header_tokens = estimate_tokens(output.len());
if header_tokens > budget {
return String::new();
}
let m... |
rust_dataset_chunk_508666 | rust_dataset.txt | 508,666 | 512 | ill
| ZetaFormat::V0211SeedCoder
| ZetaFormat::V0331SeedCoderModelPy
| ZetaFormat::v0226Hashline
| ZetaFormat::V0304SeedNoEdits
| ZetaFormat::V0304VariableEdit
| ZetaFormat::V0306SeedMultiRegions
| ZetaFormat::V0316SeedMultiRegions
| ZetaFormat::V0318SeedM... |
rust_dataset_chunk_508667 | rust_dataset.txt | 508,667 | 512 | Some(v0120_git_merge_markers::END_MARKER),
ZetaFormat::V0131GitMergeMarkersPrefix => Some(v0131_git_merge_markers_prefix::END_MARKER),
ZetaFormat::V0211Prefill => Some(v0131_git_merge_markers_prefix::END_MARKER),
ZetaFormat::V0211SeedCoder
| ZetaFormat::V0331SeedCoderModelPy
| Z... |
rust_dataset_chunk_508668 | rust_dataset.txt | 508,668 | 512 | SeedMultiRegions => {
let empty_patch = patch.lines().count() <= 3;
if empty_patch {
let marker_offsets = multi_region::compute_marker_offsets(old_editable_region);
let marker_num =
multi_region::nearest_marker_number(cursor_offset, &marker_off... |
rust_dataset_chunk_508669 | rust_dataset.txt | 508,669 | 512 | marker_tag(marker_num);
Ok(Some(format!(
"{tag}{tag}{}",
multi_region::V0327_END_MARKER
)))
} else {
Ok(None)
}
}
ZetaFormat::V0615HashRegions => Ok(None),
_ => Ok(None),
}
}
/// ... |
rust_dataset_chunk_508670 | rust_dataset.txt | 508,670 | 512 | let cursor_in_new = cursor_in_new_text(cursor_offset, first_hunk_offset, &new_editable);
multi_region::encode_from_old_and_new_v0318(
&old_editable,
&new_editable,
cursor_in_new,
CURSOR_MARKER,
multi_region::V0318_END_MARKER,
... |
rust_dataset_chunk_508671 | rust_dataset.txt | 508,671 | 512 | ZetaFormat::V0211Prefill
| ZetaFormat::V0211SeedCoder
| ZetaFormat::v0226Hashline
| ZetaFormat::V0304VariableEdit
| ZetaFormat::V0304SeedNoEdits
| ZetaFormat::V0331SeedCoderModelPy
| ZetaFormat::V0306SeedMultiRegions
| ZetaFormat::V0615HashRegions => {
... |
rust_dataset_chunk_508672 | rust_dataset.txt | 508,672 | 512 | _editable_region(
range_in_excerpt: Range<usize>,
mut new_editable_region: String,
) -> ParsedOutput {
let cursor_offset_in_new_editable_region = new_editable_region.find(CURSOR_MARKER);
if let Some(offset) = cursor_offset_in_new_editable_region {
new_editable_region.replace_range(offset..offset... |
rust_dataset_chunk_508673 | rust_dataset.txt | 508,673 | 512 | _editable_region, output)?,
),
ZetaFormat::V0318SeedMultiRegions
| ZetaFormat::V0420Diagnostics
| ZetaFormat::V0608QwenMultiRegions => (
editable_range_in_context,
multi_region::apply_marker_span_v0318(old_editable_region, output)?,
),
ZetaFormat::... |
rust_dataset_chunk_508674 | rust_dataset.txt | 508,674 | 512 | -file editable context at cursor"))?;
let (context, editable_range_in_context, context_range, _) = resolve_zeta3_cursor_region(
current_excerpt.text.as_ref(),
cursor_offset_in_excerpt,
&input.syntax_ranges,
format,
);
let old_editable_region = &context[editable_range_in_conte... |
rust_dataset_chunk_508675 | rust_dataset.txt | 508,675 | 512 | prompt_inputs.cursor_excerpt.as_ref(),
0,
parsed,
)
}
fn parsed_output_to_patch_for_excerpt(
path: &Path,
excerpt: &str,
excerpt_start_row: u32,
parsed: ParsedOutput,
) -> Result<String> {
let range_in_excerpt = parsed.range_in_excerpt;
let old_text = excerpt[range_i... |
rust_dataset_chunk_508676 | rust_dataset.txt | 508,676 | 512 | _ranges) = &input.syntax_ranges {
let (editable_tokens, context_tokens) = token_limits_for_format(format);
compute_editable_and_context_ranges(
&input.cursor_excerpt,
input.cursor_offset_in_excerpt,
syntax_ranges,
editable_tokens,
context_token... |
rust_dataset_chunk_508677 | rust_dataset.txt | 508,677 | 512 | ().rev() {
result.push_str(event_str);
}
result
}
fn excerpt_rendered_tokens(excerpt: &RelatedExcerpt, file_max_row: u32) -> usize {
let needs_newline = !excerpt.text.ends_with('\n');
let needs_ellipsis = excerpt.row_range.end < file_max_row;
let len = excerpt.text.len()
+ if needs_... |
rust_dataset_chunk_508678 | rust_dataset.txt | 508,678 | 512 | cerpt, file.max_row);
if total_tokens + header_cost + excerpt_cost > max_tokens {
break;
}
total_tokens += header_cost + excerpt_cost;
if !file_already_included {
included_file_indices[candidate.file_ix] = true;
}
included_excerpt_count += 1;
}... |
rust_dataset_chunk_508679 | rust_dataset.txt | 508,679 | 512 | path_str = file.path.to_string_lossy();
write!(prompt, "<|file_sep|>{}\n", path_str).ok();
for (excerpt_ix, excerpt) in file.excerpts.iter().enumerate() {
prompt.push_str(&excerpt.text);
if !prompt.ends_with('\n') {
prompt.push('\n');
}
le... |
rust_dataset_chunk_508680 | rust_dataset.txt | 508,680 | 512 | file_sep|>",
CURSOR_MARKER,
]
}
pub fn write_cursor_excerpt_section(
prompt: &mut String,
path: &Path,
context: &str,
editable_range: &Range<usize>,
cursor_offset: usize,
) {
let path_str = path.to_string_lossy();
write!(prompt, "<... |
rust_dataset_chunk_508681 | rust_dataset.txt | 508,681 | 512 | {
&[
"<|fim_prefix|>",
"<|fim_suffix|>",
"<|fim_middle|>",
"<|file_sep|>",
START_MARKER,
SEPARATOR,
END_MARKER,
CURSOR_MARKER,
]
}
pub fn write_cursor_excerpt_section(
prompt: &mut String,
... |
rust_dataset_chunk_508682 | rust_dataset.txt | 508,682 | 512 | "<|fim_middle|>",
"<|file_sep|>",
START_MARKER,
SEPARATOR,
END_MARKER,
CURSOR_MARKER,
]
}
pub fn write_cursor_excerpt_section(
prompt: &mut String,
path: &Path,
context: &str,
editable_range: &Range<... |
rust_dataset_chunk_508683 | rust_dataset.txt | 508,683 | 512 | == Some(&b'\n')
{
end += 1;
}
editable_region[..end].to_string()
}
// No newline found. Fall back to splitting before the last space
// (word-level boundary)
None => match prefill.rfind(' ') {
... |
rust_dataset_chunk_508684 | rust_dataset.txt | 508,684 | 512 | editable_text: &str,
cursor_offset_in_editable: usize,
) {
let mut offset = 0;
for (i, line) in editable_text.lines().enumerate() {
let (head, cursor, tail) = if cursor_offset_in_editable > offset
&& cursor_offset_in_editable < offset + line.len()
{
... |
rust_dataset_chunk_508685 | rust_dataset.txt | 508,685 | 512 | Insert {
after: Option<LineRef>,
content: &'a str,
},
}
/// Parse a line reference like `3:c3` into a `LineRef`.
fn parse_line_ref(s: &str) -> Option<LineRef> {
let (idx_str, hash_str) = s.split_once(':')?;
let index = idx_str.parse::<usize>().ok()?;
... |
rust_dataset_chunk_508686 | rust_dataset.txt | 508,686 | 512 | if let (Some(start), Some(end)) =
(parse_line_ref(start_str), parse_line_ref(end_str))
{
commands.push(EditCommand::Set {
start,
end,
content,
... |
rust_dataset_chunk_508687 | rust_dataset.txt | 508,687 | 512 | (line.as_bytes()))
.collect();
let commands = parse_edit_commands(model_output);
// For set operations: indexed by start line → Some((end line index, content))
// For insert operations: indexed by line index → vec of content to insert after
// Insert-before-first is tracked... |
rust_dataset_chunk_508688 | rust_dataset.txt | 508,688 | 512 | } else {
// Keep the original line
result.push_str(original_lines[i]);
result.push('\n');
// Emit any insertions after this line
for content in &insert_after[i] {
result.push_str(content);
... |
rust_dataset_chunk_508689 | rust_dataset.txt | 508,689 | 512 | // (used for insert-after reference).
let mut last_old_line_before_hunk: Option<usize> = None;
fn flush_hunk(
hunk: Hunk,
last_old_line: Option<usize>,
result: &mut String,
old_hashes: &[u8],
) {
if hunk.line_range.is_empty() {
... |
rust_dataset_chunk_508690 | rust_dataset.txt | 508,690 | 512 | result.push_str(line);
}
}
for raw_line in patch.split_inclusive('\n') {
if raw_line.starts_with("@@") {
// Flush any pending change hunk from a previous patch hunk.
if let Some(hunk) = current_hunk.take() {
flu... |
rust_dataset_chunk_508691 | rust_dataset.txt | 508,691 | 512 | _index..old_line_index,
new_text_lines: vec![],
cursor_line_offset_in_new_text: None,
});
hunk.new_text_lines.push(added_content);
hunk.cursor_line_offset_in_new_text = cursor_line_offset
.map(|offset_in_line| (h... |
rust_dataset_chunk_508692 | rust_dataset.txt | 508,692 | 512 | ! {"
<|file_sep|>test.rs
<|fim_prefix|>
<|fim_middle|>current
0:23|aaa
1:26|b<|user_cursor|>bb
2:29|ccc
<|fim_suffix|>
<|fim_middle|>updated
... |
rust_dataset_chunk_508693 | rust_dataset.txt | 508,693 | 512 | llo"
expected: indoc! {"
<|file_sep|>test.rs
<|fim_prefix|>
<|fim_middle|>current
0:1b|hé<|user_cursor|>llo
<|fim_suffix|>
<|fim_middle|>updated
"},
... |
rust_dataset_chunk_508694 | rust_dataset.txt | 508,694 | 512 | between lines, not placed
expected: indoc! {"
<|file_sep|>test.rs
<|fim_prefix|>
<|fim_middle|>current
0:26|abc
1:2f|def
<|fim_suffix|>
<|fim_middle|>updated
... |
rust_dataset_chunk_508695 | rust_dataset.txt | 508,695 | 512 | "},
},
Case {
name: "set_range",
original: indoc! {"
fn foo() {
let x = 1;
let y = 2;
let z = 3;
}
"},
... |
rust_dataset_chunk_508696 | rust_dataset.txt | 508,696 | 512 | _multiline_replacement",
original: indoc! {"
fn handle_submit() {
}
fn handle_keystroke() {
"},
model_output: indoc! {"
<|set|>0:3f-1:7d
fn handle_submit(modal_sta... |
rust_dataset_chunk_508697 | rust_dataset.txt | 508,697 | 512 | },
model_output: indoc! {"
<|set|>0:42-2:ff
ONE_TWO_THREE
"},
expected: indoc! {"
one
two
three
"},
},
Case {
... |
rust_dataset_chunk_508698 | rust_dataset.txt | 508,698 | 512 |
"},
expected: indoc! {"
CAT
TAIL
dog
"},
},
Case {
name: "overlapping_set_ranges_last_wins",
original: indoc! {"
a
... |
rust_dataset_chunk_508699 | rust_dataset.txt | 508,699 | 512 | total = 0;
for product in products {
total += ;
}
total
"},
patch: indoc! {"
@@ -1,5 +1,5 @@
let mut total = 0;
for product in products {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.