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_508500 | rust_dataset.txt | 508,500 | 512 | Save");
cx.run_until_parked();
will_restart
.await
.expect("reload should restart the app after the dirty item is resolved");
}
#[gpui::test]
async fn test_multi_workspace_session_restore(cx: &mut TestAppContext) {
use collections::HashMap;
use sess... |
rust_dataset_chunk_508501 | rust_dataset.txt | 508,501 | 512 |
.expect("failed to open third workspace");
window_b
.update(cx, |multi_workspace, _, cx| {
multi_workspace.open_sidebar(cx);
})
.unwrap();
// Currently dir2 is active because it was added last.
// So, switch window_a's active wor... |
rust_dataset_chunk_508502 | rust_dataset.txt | 508,502 | 512 | _by_window: HashMap<gpui::WindowId, Vec<WorkspaceId>> = HashMap::default();
for session_workspace in &locations {
if let Some(window_id) = session_workspace.window_id {
groups_by_window
.entry(window_id)
.or_default()
.push(... |
rust_dataset_chunk_508503 | rust_dataset.txt | 508,503 | 512 | (&[dir2])),
ProjectGroupKey::new(None, PathList::new(&[dir1])),
]
);
assert_eq!(mw.workspaces().count(), 1);
})
.unwrap();
// Window B (dir3): 1 workspace, 1 project group key.
restored_b
.re... |
rust_dataset_chunk_508504 | rust_dataset.txt | 508,504 | 512 | gets clobbered to dir2.
window
.update(cx, |multi_workspace, window, cx| {
let workspace = multi_workspace.workspaces().next().unwrap().clone();
multi_workspace.activate(workspace, None, window, cx);
})
.unwrap();
cx.run_until_parked()... |
rust_dataset_chunk_508505 | rust_dataset.txt | 508,505 | 512 | Workspace>())
.collect()
});
assert_eq!(restored_windows.len(), 1);
restored_windows[0]
.read_with(cx, |mw, cx| {
let active = mw.workspace().read(cx).root_paths(cx);
assert!(
active.iter().any(|p| p.as_ref() == Pat... |
rust_dataset_chunk_508506 | rust_dataset.txt | 508,506 | 512 | was not requested");
assert_eq!(restart_path, None);
assert!(restart_arguments.is_empty());
let database = cx.update(|cx| workspace::WorkspaceDb::global(cx));
let locations = workspace::last_session_workspace_locations(
&database,
&session_id,
None,
... |
rust_dataset_chunk_508507 | rust_dataset.txt | 508,507 | 512 | ![rel_path("c.txt").into(), rel_path("d.txt").into()]
),
]
);
}
#[gpui::test]
async fn test_restored_project_groups_survive_workspace_key_change(cx: &mut TestAppContext) {
use session::Session;
use util::path_list::PathList;
use workspace::{OpenMo... |
rust_dataset_chunk_508508 | rust_dataset.txt | 508,508 | 512 | Key::new(None, PathList::new(&[path!("/root_c")]));
// Make root_a the active workspace so it's the one eagerly restored.
window
.update(cx, |mw, window, cx| {
let workspace_a = mw
.workspaces()
.find(|ws| {
ws.... |
rust_dataset_chunk_508509 | rust_dataset.txt | 508,509 | 512 | .workspace().read(cx).project().clone())
.unwrap();
active_project
.update(cx, |project, cx| {
project.find_or_create_worktree(path!("/root_d"), true, cx)
})
.await
.expect("adding worktree should succeed");
cx.run_until_parked... |
rust_dataset_chunk_508510 | rust_dataset.txt | 508,510 | 512 | _project(cx: &mut TestAppContext) {
use workspace::OpenMode;
let app_state = init_test(cx);
app_state
.fs
.as_fake()
.insert_tree(path!("/project-a"), json!({}))
.await;
app_state
.fs
.as_fake()
.insert_... |
rust_dataset_chunk_508511 | rust_dataset.txt | 508,511 | 512 | _paths:?}"
);
}
async fn open_test_project_window_with_tabs(
app_state: &Arc<AppState>,
root_path: &Path,
tab_paths: &[&RelPath],
cx: &mut TestAppContext,
) -> WindowHandle<MultiWorkspace> {
let workspace::OpenResult { window, .. } = cx
.update(|c... |
rust_dataset_chunk_508512 | rust_dataset.txt | 508,512 | 512 | assert!(
!has_view_item(cx, "Agent Panel"),
"expected Agent Panel to be removed from the View menu after disabling AI"
);
assert!(
has_view_item(cx, "Diagnostics"),
"expected Diagnostics to remain in the View menu"
);
... |
rust_dataset_chunk_508513 | rust_dataset.txt | 508,513 | 512 | .await
.expect("failed to save disable_ai=true to the fake settings file");
executor.advance_clock(Duration::from_secs(2));
executor.run_until_parked();
cx.update(|cx| {
assert!(
!has_view_item(cx, "Agent Panel"),
"expected Agent Panel re... |
rust_dataset_chunk_508514 | rust_dataset.txt | 508,514 | 512 | active_path = workspace
.active_item(cx)
.and_then(|item| item.project_path(cx))
.and_then(|path| workspace.project().read(cx).absolute_path(&path, cx));
assert_eq!(active_path.as_ref(), expected_paths.last());
});
}
async fn init_startup_tes... |
rust_dataset_chunk_508515 | rust_dataset.txt | 508,515 | 512 | .as_fake()
.insert_tree(
path!("/"),
json!({
"other": { "note.txt": "note" },
"project": { "file.txt": "project file" },
"new": { "readme.txt": "readme" },
"outside.txt": "outside",
... |
rust_dataset_chunk_508516 | rust_dataset.txt | 508,516 | 512 | Vec<(String, bool)>)> {
let mut windows = cx
.windows()
.into_iter()
.map(|window| window_contents(window, cx))
.collect::<Vec<_>>();
windows.sort();
windows
}
fn window_contents(
window: gpui::AnyWindowHandle,
cx: &TestAp... |
rust_dataset_chunk_508517 | rust_dataset.txt | 508,517 | 512 | &[&str],
open_behavior: cli::OpenBehavior,
) -> (OpenRequest, mpsc::UnboundedSender<cli::CliRequest>) {
cli_connection(cli_open_request(paths, &[], open_behavior, None))
}
fn terminal_cli_request(
paths: &[&str],
open_behavior: cli::OpenBehavior,
) -> (OpenRequest, mpsc... |
rust_dataset_chunk_508518 | rust_dataset.txt | 508,518 | 512 | Buf::from(path!("/other"))], Vec::new())
}
#[gpui::test]
async fn test_startup_file_request_opens_in_its_restored_project(cx: &mut TestAppContext) {
let app_state = save_project_and_other_session(cx).await;
let (request, _cli) =
cli_request(&[path!("/project/file.txt")], cli::Op... |
rust_dataset_chunk_508519 | rust_dataset.txt | 508,519 | 512 | cx| {
let editors = multi_workspace
.workspace()
.read(cx)
.items_of_type::<Editor>(cx)
.collect::<Vec<_>>();
editors
.into_iter()
.map(|editor| {
... |
rust_dataset_chunk_508520 | rust_dataset.txt | 508,520 | 512 | , _cli) = cli_request(&[path!("/outside.txt")], cli::OpenBehavior::Default);
open_on_startup(request, &app_state, cx).await;
assert_eq!(
startup_windows(cx),
vec![(
Vec::new(),
vec![("UNSAVED".to_owned(), true), ("outside".to_owned(), false)]
... |
rust_dataset_chunk_508521 | rust_dataset.txt | 508,521 | 512 | TestAppContext,
) {
let app_state = save_project_and_other_session(cx).await;
let (request, _cli) = cli_request(
&[path!("/project"), path!("/project/file.txt")],
cli::OpenBehavior::AlwaysNew,
);
open_on_startup(request, &app_state, cx).await;
assert... |
rust_dataset_chunk_508522 | rust_dataset.txt | 508,522 | 512 | async fn test_startup_new_window_request_restores_a_window_without_folders(
cx: &mut TestAppContext,
) {
let app_state = save_session_without_folders(cx).await;
let (request, _cli) = cli_request(&[], cli::OpenBehavior::AlwaysNew);
open_on_startup(request, &app_state, cx).await;
... |
rust_dataset_chunk_508523 | rust_dataset.txt | 508,523 | 512 | PathBuf::from(path!("/project/file.txt")),
],
app_state.clone(),
cx,
)
.await;
restart_startup_test_session(&app_state, cx).await;
app_state
}
fn run_until_a_window_opens(cx: &mut TestAppContext) {
let mut steps = 0;
while cx.... |
rust_dataset_chunk_508524 | rust_dataset.txt | 508,524 | 512 | Window);
open_on_startup(request, &app_state, cx).await;
assert_eq!(
startup_windows(cx),
vec![
(vec![PathBuf::from(path!("/new"))], Vec::new()),
(vec![PathBuf::from(path!("/open"))], Vec::new()),
]
);
}
#[gpui::test]
... |
rust_dataset_chunk_508525 | rust_dataset.txt | 508,525 | 512 | },
"notes.txt": "notes",
}),
)
.await;
open_test_workspace_paths(
vec![PathBuf::from(path!("/project"))],
app_state.clone(),
cx,
)
.await;
let notes_window = open_test_workspace_paths(
... |
rust_dataset_chunk_508526 | rust_dataset.txt | 508,526 | 512 | .await
.unwrap();
window
.update(cx, |multi_workspace, window, cx| {
let project_workspace = multi_workspace
.workspaces()
.find(|workspace| {
workspace.read(cx).root_paths(cx)
==... |
rust_dataset_chunk_508527 | rust_dataset.txt | 508,527 | 512 | }, "old": { "note.txt": "" } }),
)
.await;
open_test_workspace_paths(vec![PathBuf::from(path!("/target"))], app_state.clone(), cx)
.await;
restart_startup_test_session(&app_state, cx).await;
open_test_workspace_paths(vec![PathBuf::from(path!("/old"))], app_state.clon... |
rust_dataset_chunk_508528 | rust_dataset.txt | 508,528 | 512 | ignore_if_not_exists: false,
},
)
.await
.unwrap();
fs.create_symlink(Path::new(path!("/old")), PathBuf::from(path!("/target")))
.await
.unwrap();
let (request, _cli) = cli_request(&[path!("/target")], cli::OpenBehavior::AlwaysNew);
o... |
rust_dataset_chunk_508529 | rust_dataset.txt | 508,529 | 512 | .clone()]);
let (request, _cli) = cli_request(&[], cli::OpenBehavior::ExistingWindow);
cx.update(|cx| crate::handle_open_request(request, app_state.clone(), cx));
cx.run_until_parked();
assert_eq!(
startup_windows(cx),
vec![
outside_window,
... |
rust_dataset_chunk_508530 | rust_dataset.txt | 508,530 | 512 | } else {
"project file"
};
cx.run_until_parked();
let mut expected_windows = vec![
(restored_roots, vec![(restored_tab.to_owned(), false)]),
(
vec![PathBuf::from(path!("/outside.txt"))],
vec![("outside".to_owned(), false)],
... |
rust_dataset_chunk_508531 | rust_dataset.txt | 508,531 | 512 | (vec![PathBuf::from(root)], app_state.clone(), cx).await;
}
restart_startup_test_session(&app_state, cx).await;
let (request, _cli) =
terminal_cli_request(&[path!("/repo-wt")], cli::OpenBehavior::Default);
open_on_startup(request, &app_state, cx).await;
assert_eq!(
... |
rust_dataset_chunk_508532 | rust_dataset.txt | 508,532 | 512 | target/file.txt")),
],
app_state.clone(),
cx,
)
.await;
restart_startup_test_session(&app_state, cx).await;
open_test_workspace_paths(vec![PathBuf::from(path!("/old"))], app_state.clone(), cx).await;
restart_startup_test_session(&app_state, cx)... |
rust_dataset_chunk_508533 | rust_dataset.txt | 508,533 | 512 | _eq!(
window_contents(project_window.into(), cx),
(vec![PathBuf::from(path!("/project"))], Vec::new())
);
project_window
}
async fn start_until_a_window_is_restoring(
app_state: &Arc<AppState>,
cx: &mut TestAppContext,
) -> WindowHandle<MultiWorkspace... |
rust_dataset_chunk_508534 | rust_dataset.txt | 508,534 | 512 | let (app_state, _) = start_with_a_project_window_that_is_still_restoring(cx).await;
quit_without_finishing_restores(cx).await;
restart_startup_test_session(&app_state, cx).await;
let (request, _cli) = cli_request(&[], cli::OpenBehavior::Default);
open_on_startup(request, &app_st... |
rust_dataset_chunk_508535 | rust_dataset.txt | 508,535 | 512 | (), Vec::new()));
open_tab_with_text(window, "opened meanwhile", cx);
cx.run_until_parked();
let mut texts = window_contents(window.into(), cx)
.1
.into_iter()
.map(|(text, _)| text)
.collect::<Vec<_>>();
texts.sort();
assert_eq!(t... |
rust_dataset_chunk_508536 | rust_dataset.txt | 508,536 | 512 | _eq!(
project_windows(cx),
vec![vec![("project file".to_owned(), false)]]
);
}
#[gpui::test]
async fn test_window_whose_restore_was_cancelled_is_saved_as_it_is(cx: &mut TestAppContext) {
let app_state = save_session_with_a_project_tab(cx).await;
let saved = c... |
rust_dataset_chunk_508537 | rust_dataset.txt | 508,537 | 512 | : &TestAppContext| {
window
.read_with(cx, |multi_workspace, cx| {
let pane = multi_workspace.workspace().read(cx).active_pane().read(cx);
let tabs = pane
.items()
.filter_map(|item| item.downcast::<Edito... |
rust_dataset_chunk_508538 | rust_dataset.txt | 508,538 | 512 | window, cx));
workspace.add_item_to_active_pane(Box::new(editor), None, true, window, cx);
})
})
.unwrap();
quit_without_finishing_restores(cx).await;
restart_startup_test_session(&app_state, cx).await;
let (request, _cli) = cli_reque... |
rust_dataset_chunk_508539 | rust_dataset.txt | 508,539 | 512 | _without_finishing_restores(cx: &mut TestAppContext) {
let mut flushes = Vec::new();
for window in cx.windows() {
let window = window.downcast::<MultiWorkspace>().unwrap();
flushes.extend(
window
.update(cx, |multi_workspace, window, cx| {
... |
rust_dataset_chunk_508540 | rust_dataset.txt | 508,540 | 512 | (request, &app_state, cx).await;
assert_eq!(
startup_windows(cx),
vec![
other_window(),
project_window_with(&[("project draft", true)]),
project_file_window(),
]
);
assert_eq!(
cli_environment_of(pat... |
rust_dataset_chunk_508541 | rust_dataset.txt | 508,541 | 512 | .clone(),
cx,
)
.await;
restart_startup_test_session(&app_state, cx).await;
cx.executor().advance_clock(Duration::from_millis(50));
cx.run_until_parked();
let saved = crate::restorable_workspaces(&mut cx.to_async(), &app_state)
.await
.... |
rust_dataset_chunk_508542 | rust_dataset.txt | 508,542 | 512 | (|cx| {
crate::open_startup_request(request, app_state.clone(), futures::future::ready(()), cx)
})
.await;
cx.run_until_parked();
assert_eq!(startup_windows(cx), Vec::new());
cli_requests
.unbounded_send(cli_open_request(
&[path!("/outside... |
rust_dataset_chunk_508543 | rust_dataset.txt | 508,543 | 512 | ver().is_none());
assert_eq!(
startup_windows(cx)
.into_iter()
.map(|(roots, _)| roots)
.collect::<Vec<_>>(),
vec![vec![PathBuf::from(path!("/project"))]]
);
ready.await;
assert_eq!(
active_window_roots(... |
rust_dataset_chunk_508544 | rust_dataset.txt | 508,544 | 512 | } if name == item_name))
}
}
--- FILE: zed/crates/zed/src/zed/telemetry_log.rs ---
use std::collections::VecDeque;
use std::sync::Arc;
use time::OffsetDateTime;
use client::telemetry::Telemetry;
use collections::{HashMap, HashSet};
use fs::Fs;
use futures::StreamExt;
use gpui::{
App, Empty, Entity, EventEm... |
rust_dataset_chunk_508545 | rust_dataset.txt | 508,545 | 512 | : SharedString,
event_properties: HashMap<String, serde_json::Value>,
signed_in: bool,
collapsed_md: Option<Entity<Markdown>>,
expanded_md: Option<Entity<Markdown>>,
}
impl TelemetryLogEntry {
fn props_as_json_object(&self) -> serde_json::Value {
serde_json::Value::Object(
self.... |
rust_dataset_chunk_508546 | rust_dataset.txt | 508,546 | 512 | (
SharedString,
std::collections::HashMap<String, serde_json::Value>,
) = match &event_wrapper.event {
Event::Flexible(flexible) => (
flexible.event_type.clone().into(),
flexible.event_properties.clone(),
),
};
let... |
rust_dataset_chunk_508547 | rust_dataset.txt | 508,547 | 512 |
}
fn recompute_filtered_indices(&mut self) {
self.filtered_indices.clear();
for (idx, entry) in self.events.iter().enumerate() {
if self.entry_matches_filter(entry) {
self.filtered_indices.push(idx);
}
}
self.list_state.reset(self.filtere... |
rust_dataset_chunk_508548 | rust_dataset.txt | 508,548 | 512 | _index);
let local_timezone =
time::UtcOffset::current_local_offset().unwrap_or(time::UtcOffset::UTC);
let timestamp_str = time_format::format_localized_timestamp(
entry.received_at,
OffsetDateTime::now_utc(),
local_timezone,
time_format::Time... |
rust_dataset_chunk_508549 | rust_dataset.txt | 508,549 | 512 | {
IconName::ChevronRight
})
.color(Color::Muted)
.size(IconSize::Small),
)
.child(
Label::new(timestamp_str)
.buffer_font(cx)
... |
rust_dataset_chunk_508550 | rust_dataset.txt | 508,550 | 512 | );
cx.new(|cx| Markdown::new(params_md.into(), Some(language_registry.clone()), None, cx))
}
fn expanded_params_md(
params: &serde_json::Value,
language_registry: &Arc<LanguageRegistry>,
cx: &mut App,
) -> Entity<Markdown> {
let params_json = serde_json::to_string_pretty(params).unwrap_or_default()... |
rust_dataset_chunk_508551 | rust_dataset.txt | 508,551 | 512 | >>,
search_editor: Entity<editor::Editor>,
}
impl TelemetryLogToolbarItemView {
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
let search_editor = cx.new(|cx| {
let mut editor = editor::Editor::single_line(window, cx);
editor.set_placeholder_text("Filter event... |
rust_dataset_chunk_508552 | rust_dataset.txt | 508,552 | 512 | impl ToolbarItemView for TelemetryLogToolbarItemView {
fn set_active_pane_item(
&mut self,
active_pane_item: Option<&dyn ItemHandle>,
_window: &mut Window,
cx: &mut Context<Self>,
) -> ToolbarItemLocation {
if let Some(item) = active_pane_item
&& let Some(tele... |
rust_dataset_chunk_508553 | rust_dataset.txt | 508,553 | 512 | };
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
use workspace::AppState;
/// Initialize a visual test context with all necessary Zed subsystems.
pub fn init_visual_test(cx: &mut VisualTestAppContext) -> Arc<AppState> {
cx.update(|cx| {
env_logger::builder().is_test(true).try_init().ok(... |
rust_dataset_chunk_508554 | rust_dataset.txt | 508,554 | 512 | arked();
Ok(window)
}
/// Returns the default window size for visual tests (1280x800).
pub fn default_window_size() -> Size<gpui::Pixels> {
size(px(1280.0), px(800.0))
}
/// Waits for the UI to stabilize by running pending work and waiting for animations.
pub async fn wait_for_ui_stabilization(cx: &VisualTes... |
rust_dataset_chunk_508555 | rust_dataset.txt | 508,555 | 512 | pub match_percentage: f64,
/// Optional diff image highlighting differences (red = different, green = same)
pub diff_image: Option<RgbaImage>,
/// Number of pixels that differ
pub diff_pixel_count: u64,
/// Total number of pixels compared
pub total_pixels: u64,
}
impl ScreenshotComparison {
... |
rust_dataset_chunk_508556 | rust_dataset.txt | 508,556 | 512 | ]));
}
}
}
let matching_pixels = total_pixels - diff_pixel_count;
let match_percentage = if total_pixels > 0 {
matching_pixels as f64 / total_pixels as f64
} else {
1.0
};
ScreenshotComparison {
match_percentage,
diff_image: Some(diff_image),... |
rust_dataset_chunk_508557 | rust_dataset.txt | 508,557 | 512 | } else {
let diff_path = baseline_path.with_extension("diff.png");
if let Some(diff_image) = &comparison.diff_image {
diff_image.save(&diff_path).ok();
}
let actual_path = baseline_path.with_extension("actual.png");
actual.save(&actual_path).ok();
Err(an... |
rust_dataset_chunk_508558 | rust_dataset.txt | 508,558 | 512 | , &img2, 0);
assert_eq!(comparison.match_percentage, 1.0);
assert_eq!(comparison.diff_pixel_count, 0);
assert!(comparison.matches(0.0));
}
#[test]
fn test_different_images_dont_match() {
let img1 = create_test_image(100, 100, Rgba([255, 0, 0, 255]));
let img2 = crea... |
rust_dataset_chunk_508559 | rust_dataset.txt | 508,559 | 512 | ..100 {
img1.put_pixel(x, y, Rgba([0, 255, 0, 255]));
}
}
let comparison = compare_screenshots(&img1, &img2, 0);
assert_eq!(comparison.match_percentage, 0.5);
assert_eq!(comparison.diff_pixel_count, 5000);
assert!(comparison.matches(0.5));
as... |
rust_dataset_chunk_508560 | rust_dataset.txt | 508,560 | 512 | let app_state = init_visual_test(&mut cx);
gpui::block_on(async {
app_state
.fs
.as_fake()
.insert_tree(
"/project",
serde_json::json!({
"src": {
"main... |
rust_dataset_chunk_508561 | rust_dataset.txt | 508,561 | 512 | parse_path_with_position};
use windows::{
Win32::{
Foundation::{CloseHandle, ERROR_ALREADY_EXISTS, GENERIC_WRITE, GetLastError, HANDLE},
Storage::FileSystem::{
CreateFileW, FILE_FLAGS_AND_ATTRIBUTES, FILE_SHARE_MODE, OPEN_EXISTING,
PIPE_ACCESS_INBOUND, ReadFile, WriteFile,
... |
rust_dataset_chunk_508562 | rust_dataset.txt | 508,562 | 512 | );
}
}
}
fn retrieve_message_from_pipe(pipe: HANDLE) -> anyhow::Result<String> {
unsafe { ConnectNamedPipe(pipe, None)? };
let message = retrieve_message_from_pipe_inner(pipe);
unsafe { DisconnectNamedPipe(pipe).log_err() };
message
}
fn retrieve_message_from_pipe_inner(pipe: HANDLE) -> an... |
rust_dataset_chunk_508563 | rust_dataset.txt | 508,563 | 512 | diff_paths.push([
old.to_string_lossy().into_owned(),
new.to_string_lossy().into_owned(),
]);
}
}
CliRequest::Open {
paths,
urls,
diff_paths,
diff_all: false,
wait: false,
... |
rust_dataset_chunk_508564 | rust_dataset.txt | 508,564 | 512 | {
use super::split_paths_and_urls;
#[test]
fn test_split_paths_and_urls() {
let file = concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml");
let canonical = std::fs::canonicalize(file).unwrap();
let url = "zed://file/C:/project/main.rs:3";
let (paths, urls) = split_paths_and... |
rust_dataset_chunk_508565 | rust_dataset.txt | 508,565 | 512 | : usize,
syntax_ranges: &[Range<usize>],
) -> ExcerptRanges {
let compute = |editable_tokens, context_tokens| {
compute_editable_and_context_ranges(
cursor_excerpt,
cursor_offset,
syntax_ranges,
editable_tokens,
context_tokens,
)
};... |
rust_dataset_chunk_508566 | rust_dataset.txt | 508,566 | 512 | ().saturating_sub(1) as u32;
let editable_range = compute_editable_range_from_text(
cursor_excerpt,
&line_starts,
cursor_row,
max_row,
syntax_ranges,
editable_token_limit,
);
let context_range = expand_context_from_text(
cursor_excerpt,
&line... |
rust_dataset_chunk_508567 | rust_dataset.txt | 508,567 | 512 | line_token_count_from_text(text: &str, line_starts: &[usize], row: u32) -> usize {
let row_len =
row_end_offset(text, line_starts, row).saturating_sub(row_start_offset(line_starts, row));
estimate_tokens(row_len).max(1)
}
/// Returns syntax boundaries (as row ranges) that contain the given row range
/... |
rust_dataset_chunk_508568 | rust_dataset.txt | 508,568 | 512 | _row {
estimate_tokens_for_row_range(text, line_starts, *boundary_start, start_row)
} else {
0
};
let tokens_for_end = if *boundary_end > end_row {
estimate_tokens_for_row_range(text, line_starts, end_row + 1, *boundary_end + 1)
} else {
0
... |
rust_dataset_chunk_508569 | rust_dataset.txt | 508,569 | 512 | let total_needed = tokens_for_start + tokens_for_end;
if total_needed <= remaining_tokens {
if *boundary_start < start_row {
start_row = *boundary_start;
}
if *boundary_end > end_row {
end_row = *boundary_end;
}
remaini... |
rust_dataset_chunk_508570 | rust_dataset.txt | 508,570 | 512 | _row: u32,
mut end_row: u32,
max_row: u32,
mut remaining_tokens: usize,
prefer_up: bool,
) -> (u32, u32, usize) {
loop {
let can_expand_up = start_row > 0;
let can_expand_down = end_row < max_row;
if remaining_tokens == 0 || (!can_expand_up && !can_expand_down) {
... |
rust_dataset_chunk_508571 | rust_dataset.txt | 508,571 | 512 | //!
//! Hashed identifiers are self-describing: a tag can be mapped back to its
//! location without reproducing the exact rendering order of the prompt, so
//! markers can be placed across *all* prompt context, and budget-based
//! truncation of related files doesn't shift the addressing of the remaining
//! markers. ... |
rust_dataset_chunk_508572 | rust_dataset.txt | 508,572 | 512 | build_editable_marker_table(input: &Zeta2PromptInput) -> Vec<SnippetMarkers> {
build_marker_table_with_filter(input, is_hash_region_editable_context_source)
}
pub fn is_hash_region_editable_context_source(context_source: ContextSource) -> bool {
matches!(
context_source,
ContextSource::Current... |
rust_dataset_chunk_508573 | rust_dataset.txt | 508,573 | 512 | encode_tag_id(hash_with_seed(content, seed));
if used_ids.insert(id.clone()) {
return id;
}
seed += 1;
}
}
/// FNV-1a, with the seed folded in ahead of the content.
fn hash_with_seed(content: &str, seed: u64) -> u64 {
const FNV_OFFSET: u64 = 0xcbf29ce484222325;
const FN... |
rust_dataset_chunk_508574 | rust_dataset.txt | 508,574 | 512 | }
_ => output.push_str(block),
}
}
}
}
/// Extract a marker-bounded span from a model-output codeblock.
///
/// Returns `(start tag id, end tag id, content)` where `content` is the text
/// between the first and last marker tags, with any intermediate marker tags... |
rust_dataset_chunk_508575 | rust_dataset.txt | 508,575 | 512 | end_id.to_string(), content))
}
pub struct RelatedFileCursor {
pub file_ix: usize,
pub excerpt_ix: usize,
pub offset_in_excerpt: usize,
}
struct ParseSnippet<'a> {
file_ix: usize,
first_excerpt_ix: usize,
last_excerpt_ix: usize,
end_row: u32,
text: Cow<'a, str>,
markers: Vec<(Stri... |
rust_dataset_chunk_508576 | rust_dataset.txt | 508,576 | 512 | _excerpt)?;
let line_len = excerpt.text[line_start..]
.lines()
.next()
.unwrap_or("")
.len();
if cursor_column <= line_len {
return Some(RelatedFileCursor {
file_ix,
excerpt_ix... |
rust_dataset_chunk_508577 | rust_dataset.txt | 508,577 | 512 | _source: ContextSource::CurrentFile,
};
let cursor_path = input.cursor_path.clone();
let in_open_source_repo = input.in_open_source_repo;
let related_files = input.related_files.get_or_insert_with(Vec::new);
if let Some(file) = related_files
.iter_mut()
.find(|file| related_file_pat... |
rust_dataset_chunk_508578 | rust_dataset.txt | 508,578 | 512 | }
let base = text.len();
text.push_str(&excerpt.text);
last.markers.extend(
snippet
.markers
.into_iter()
.map(|(id, offset)| (id, base + offset)),
);
last.last_excerpt_ix = snippet.e... |
rust_dataset_chunk_508579 | rust_dataset.txt | 508,579 | 512 | .map(|(id, _)| id.as_str())
.unwrap_or("unknown")
}
/// Encode a single marker-bounded edit block for one snippet, given its old and
/// new text. The returned block starts and ends with a marker tag and does
/// **not** include the output end marker; callers concatenate blocks and append
/// [`V0615_E... |
rust_dataset_chunk_508580 | rust_dataset.txt | 508,580 | 512 | if let Some(cursor_offset) = cursor_offset_in_new {
if cursor_offset >= new_start && cursor_offset <= new_end {
let cursor_in_span = cursor_offset - new_start;
result.push_str(&new_span[..cursor_in_span]);
result.push_str(cursor_marker);
result.push_str(&new_s... |
rust_dataset_chunk_508581 | rust_dataset.txt | 508,581 | 512 | /// at a time. Returns `(start_id, end_id, raw_new_span)` per pair, where
/// `raw_new_span` may still contain the cursor marker.
fn pair_marker_spans(output: &str) -> Result<Vec<(String, String, String)>> {
let tags = find_all_marker_tags(output);
if tags.len() < 2 {
return Err(anyhow!("output does not... |
rust_dataset_chunk_508582 | rust_dataset.txt | 508,582 | 512 | snippet are skipped (lenient). The cursor marker is honored in
/// every region that contains it; the returned [`HashRegionCursor`] reports the
/// first such position.
pub fn build_patch_from_spans(
input: &Zeta2PromptInput,
spans: &[(String, String, String)],
cursor_marker: &str,
) -> Result<(String, Opt... |
rust_dataset_chunk_508583 | rust_dataset.txt | 508,583 | 512 | .ends_with('\n') {
new_span.pop();
}
}
if !new_span.is_empty()
&& let Some(dropped) = detect_trailing_deletion(old_span, &new_span)
{
return Err(anyhow!(
"edit span `{start_id}`..`{end_id}` looks truncated: the replacement \
... |
rust_dataset_chunk_508584 | rust_dataset.txt | 508,584 | 512 | in snippet_edits {
if !accepted.is_empty() && edit.range.start < last_end {
continue;
}
last_end = edit.range.end;
accepted.push(edit);
}
let old_text = snippet.text.as_ref();
let (path, start_row) = snippet_path_and_start_row(inp... |
rust_dataset_chunk_508585 | rust_dataset.txt | 508,585 | 512 | : &str) -> Option<String> {
let non_blank_deleted = deleted_tail
.lines()
.filter(|line| !line.trim().is_empty())
.count();
(non_blank_deleted > MAX_TRAILING_DELETED_LINES)
.then(|| deleted_tail.trim_end().to_string())
}
// A verbatim prefix is ch... |
rust_dataset_chunk_508586 | rust_dataset.txt | 508,586 | 512 | **one marker-bounded block per diff hunk**, in patch order (which
/// preserves the teacher's cross-file ordering), with no markdown code fences,
/// terminated by a single [`V0615_END_MARKER`]. Blocks are separated by a
/// newline; the parser re-pairs marker tags two at a time, so the separator is
/// not significan... |
rust_dataset_chunk_508587 | rust_dataset.txt | 508,587 | 512 | let Some(hunk_offset) =
udiff::disambiguate_by_line_number(&candidates, hunk.start_line, &|offset| {
start_row + old_text[..offset].matches('\n').count() as u32
})
else {
continue;
};
let mut new_text = old_text.to_string();
fo... |
rust_dataset_chunk_508588 | rust_dataset.txt | 508,588 | 512 | let excerpt = RelatedExcerpt {
row_range: row..row + row_count,
text: Arc::from(*text),
order: 0,
context_source: ContextSou... |
rust_dataset_chunk_508589 | rust_dataset.txt | 508,589 | 512 | (
"fn main() {\n let x = 1;\n}\n",
&[("src/main.rs", &["fn main() {\n let x = 1;\n}\n"])],
);
input.cursor_offset_in_excerpt = 16;
let before = input.clone();
assert!(ensure_cursor_file_excerpt(&mut input));
assert_eq!(input, before);
}
#[te... |
rust_dataset_chunk_508590 | rust_dataset.txt | 508,590 | 512 | test]
fn test_write_snippet_with_markers_and_cursor() {
let text = "fn main() {\n let x = 1;\n}\n";
let markers = vec![("aaaa".to_string(), 0), ("bbbb".to_string(), text.len())];
let mut output = String::new();
write_snippet_with_markers(&mut output, text, &markers, Some((16, "<|u... |
rust_dataset_chunk_508591 | rust_dataset.txt | 508,591 | 512 | " fn alpha() {\n",
"- one();\n",
"+ uno();\n",
" }\n",
"@@ -9,3 +9,3 @@\n",
" fn gamma() {\n",
"- three();\n",
"+ tres();\n",
" }\n",
);
#[test]
fn test_encode_multi_hunk_emits_multiple_blocks() {
let input = make_input(MU... |
rust_dataset_chunk_508592 | rust_dataset.txt | 508,592 | 512 | +1,1 @@\n-gone();\n+kept();\n"
);
let input = make_input(MULTI_FN_EXCERPT, &[("src/main.rs", &[MULTI_FN_EXCERPT])]);
let output = encode_patch_as_output(&input, &patch, None, "<|user_cursor|>").unwrap();
assert_ne!(output.trim_end_matches(V0615_END_MARKER), NO_EDITS);
assert!(o... |
rust_dataset_chunk_508593 | rust_dataset.txt | 508,593 | 512 | tag(0),
new_first,
tag(1),
tag(1),
new_second,
tag(markers.len() - 1),
V0615_END_MARKER,
);
let patch = parse_output_as_patch(&input, &output, "<|user_cursor|>").unwrap();
assert!(patch.contains("+ uno();"), "patch: {pa... |
rust_dataset_chunk_508594 | rust_dataset.txt | 508,594 | 512 | ();
let mut offset = 0;
for line in text.split('\n') {
let trimmed = line.trim();
let is_blank = trimmed.is_empty();
let is_good_start = !is_blank && !is_structural_tail(trimmed);
lines.push(LineInfo {
start: offset,
is_blank,
is_good_start,
... |
rust_dataset_chunk_508595 | rust_dataset.txt | 508,595 | 512 | return vec![0, 0];
}
let lines = collect_line_info(editable_text);
let mut offsets = vec![0usize];
let mut last_boundary_line = 0;
let mut i = 0;
while i < lines.len() {
let gap = i - last_boundary_line;
// Blank-line split: non-blank line following blank line(s) with enough
... |
rust_dataset_chunk_508596 | rust_dataset.txt | 508,596 | 512 | {
let bounded_offset = text.floor_char_boundary(offset.min(text.len()));
text[..bounded_offset]
.rfind('\n')
.map(|index| index + 1)
.unwrap_or(0)
}
fn line_end_at_or_after(text: &str, offset: usize) -> usize {
let bounded_offset = text.floor_char_boundary(offset.min(text.len()));
... |
rust_dataset_chunk_508597 | rust_dataset.txt | 508,597 | 512 | let last_marker_index = marker_offsets.len() - 1;
let end_marker_index = if candidate_cursor_offset <= marker_offsets[last_internal_marker_index]
{
last_internal_marker_index
} else {
last_marker_index
};
let trimmed_start = candidate_range.start + marker_offsets[first_internal_... |
rust_dataset_chunk_508598 | rust_dataset.txt | 508,598 | 512 | } else {
output.push_str(block);
}
}
}
}
/// Strip any `<|marker_N|>` tags from `text`.
///
/// When a marker tag sits on its own line (followed by `\n`), the trailing
/// newline is also removed so the surrounding lines stay joined naturally.
pub(crate) fn strip_marker_tags(te... |
rust_dataset_chunk_508599 | rust_dataset.txt | 508,599 | 512 | _start = text
.rfind(MARKER_TAG_PREFIX)
.context("no end marker found in output")?;
let last_num_start = last_tag_start + MARKER_TAG_PREFIX.len();
let last_num_end = text[last_num_start..]
.find(MARKER_TAG_SUFFIX)
.map(|i| i + last_num_start)
.context("malformed end marke... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.