Skip to content

Commit 3abc31d

Browse files
authored
Improve R (ark) snippets based on source code analysis (#52)
- Fix update_display_data to create separate plots instead of adding points to existing plot. Ark sends update_display_data when a new plot replaces the previous one on the same graphics page. - Add rich_execute_result support for R. Ark returns text/html in execute_result for data frames, not just via display_data.
1 parent 8b8f79f commit 3abc31d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/snippets.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ impl LanguageSnippets {
101101
completion_prefix: "test_variable_for_",
102102
// Ark produces display_data natively for graphics - no IRdisplay needed
103103
display_data_code: "plot(1:10)",
104-
// Note: update_display_data may not trigger in batch mode; Ark may optimize to single render
105-
update_display_data_code: "plot(1:10); points(5, 5, col='red', pch=19)",
106-
// R doesn't typically produce rich execute_result, uses display_data instead
107-
rich_execute_result_code: "// R uses display_data for rich output",
104+
// Ark sends update_display_data when a new plot replaces the previous one
105+
update_display_data_code: "plot(1:5); Sys.sleep(0.1); plot(6:10)",
106+
// Ark returns text/html in execute_result for data frames
107+
rich_execute_result_code: "data.frame(x = 1:3, y = c('a', 'b', 'c'))",
108108
}
109109
}
110110

0 commit comments

Comments
 (0)