Skip to content

Commit 5bdbe5d

Browse files
committed
Send OpenFile request with kind field
1 parent 21f11d9 commit 5bdbe5d

File tree

6 files changed

+43
-16
lines changed

6 files changed

+43
-16
lines changed

crates/amalthea/src/comm/data_explorer_comm.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ pub enum SearchSchemaSortOrder {
706706
}
707707

708708
/// Possible values for ColumnDisplayType
709-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
709+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
710710
pub enum ColumnDisplayType {
711711
#[serde(rename = "number")]
712712
#[strum(to_string = "number")]
@@ -754,7 +754,7 @@ pub enum ColumnDisplayType {
754754
}
755755

756756
/// Possible values for Condition in RowFilter
757-
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
757+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
758758
pub enum RowFilterCondition {
759759
#[serde(rename = "and")]
760760
#[strum(to_string = "and")]
@@ -766,7 +766,7 @@ pub enum RowFilterCondition {
766766
}
767767

768768
/// Possible values for RowFilterType
769-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
769+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
770770
pub enum RowFilterType {
771771
#[serde(rename = "between")]
772772
#[strum(to_string = "between")]
@@ -814,7 +814,7 @@ pub enum RowFilterType {
814814
}
815815

816816
/// Possible values for Op in FilterComparison
817-
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
817+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
818818
pub enum FilterComparisonOp {
819819
#[serde(rename = "=")]
820820
#[strum(to_string = "=")]
@@ -842,7 +842,7 @@ pub enum FilterComparisonOp {
842842
}
843843

844844
/// Possible values for TextSearchType
845-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
845+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
846846
pub enum TextSearchType {
847847
#[serde(rename = "contains")]
848848
#[strum(to_string = "contains")]
@@ -866,7 +866,7 @@ pub enum TextSearchType {
866866
}
867867

868868
/// Possible values for ColumnFilterType
869-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
869+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
870870
pub enum ColumnFilterType {
871871
#[serde(rename = "text_search")]
872872
#[strum(to_string = "text_search")]
@@ -878,7 +878,7 @@ pub enum ColumnFilterType {
878878
}
879879

880880
/// Possible values for ColumnProfileType
881-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
881+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
882882
pub enum ColumnProfileType {
883883
#[serde(rename = "null_count")]
884884
#[strum(to_string = "null_count")]
@@ -906,7 +906,7 @@ pub enum ColumnProfileType {
906906
}
907907

908908
/// Possible values for Method in ColumnHistogramParams
909-
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
909+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
910910
pub enum ColumnHistogramParamsMethod {
911911
#[serde(rename = "sturges")]
912912
#[strum(to_string = "sturges")]
@@ -926,7 +926,7 @@ pub enum ColumnHistogramParamsMethod {
926926
}
927927

928928
/// Possible values for Kind in TableSelection
929-
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
929+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
930930
pub enum TableSelectionKind {
931931
#[serde(rename = "single_cell")]
932932
#[strum(to_string = "single_cell")]
@@ -954,7 +954,7 @@ pub enum TableSelectionKind {
954954
}
955955

956956
/// Possible values for ExportFormat
957-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
957+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
958958
pub enum ExportFormat {
959959
#[serde(rename = "csv")]
960960
#[strum(to_string = "csv")]
@@ -970,7 +970,7 @@ pub enum ExportFormat {
970970
}
971971

972972
/// Possible values for SupportStatus
973-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
973+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
974974
pub enum SupportStatus {
975975
#[serde(rename = "unsupported")]
976976
#[strum(to_string = "unsupported")]

crates/amalthea/src/comm/help_comm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use serde::Deserialize;
1212
use serde::Serialize;
1313

1414
/// Possible values for Kind in ShowHelp
15-
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
15+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
1616
pub enum ShowHelpKind {
1717
#[serde(rename = "html")]
1818
#[strum(to_string = "html")]

crates/amalthea/src/comm/plot_comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct PlotRenderSettings {
6464
}
6565

6666
/// Possible values for PlotUnit
67-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
67+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
6868
pub enum PlotUnit {
6969
#[serde(rename = "pixels")]
7070
#[strum(to_string = "pixels")]
@@ -76,7 +76,7 @@ pub enum PlotUnit {
7676
}
7777

7878
/// Possible values for PlotRenderFormat
79-
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display)]
79+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
8080
pub enum PlotRenderFormat {
8181
#[serde(rename = "png")]
8282
#[strum(to_string = "png")]

crates/amalthea/src/comm/ui_comm.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ pub struct Range {
9898
pub end: Position
9999
}
100100

101+
/// Possible values for Kind in OpenEditor
102+
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, strum_macros::Display, strum_macros::EnumString)]
103+
pub enum OpenEditorKind {
104+
#[serde(rename = "path")]
105+
#[strum(to_string = "path")]
106+
Path,
107+
108+
#[serde(rename = "uri")]
109+
#[strum(to_string = "uri")]
110+
Uri
111+
}
112+
101113
/// Parameters for the DidChangePlotsRenderSettings method.
102114
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
103115
pub struct DidChangePlotsRenderSettingsParams {
@@ -133,6 +145,10 @@ pub struct OpenEditorParams {
133145

134146
/// The column number to jump to
135147
pub column: i64,
148+
149+
/// How to interpret the 'file' argument: as a file path or as a URI. If
150+
/// omitted, defaults to 'path'.
151+
pub kind: OpenEditorKind,
136152
}
137153

138154
/// Parameters for the NewDocument method.

crates/ark/src/modules/positron/frontend-methods.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
column = 0L
4040
) {
4141
# Don't normalize if that's an `ark:` URI
42-
if (!grepl("^ark:", file)) {
42+
if (grepl("^ark:", file)) {
43+
kind <- "uri"
44+
} else {
45+
kind <- "path"
4346
file <- normalizePath(file)
4447
}
4548

@@ -51,7 +54,7 @@
5154
column <- 0L
5255
}
5356

54-
.ps.Call("ps_ui_navigate_to_file", file, line, column)
57+
.ps.Call("ps_ui_navigate_to_file", file, line, column, kind)
5558
}
5659

5760
#' @export

crates/ark/src/ui/events.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
//
66
//
77

8+
use std::str::FromStr;
9+
10+
use amalthea::comm::ui_comm::OpenEditorKind;
811
use amalthea::comm::ui_comm::OpenEditorParams;
912
use amalthea::comm::ui_comm::OpenWithSystemParams;
1013
use amalthea::comm::ui_comm::OpenWorkspaceParams;
@@ -63,11 +66,16 @@ pub unsafe extern "C-unwind" fn ps_ui_navigate_to_file(
6366
file: SEXP,
6467
line: SEXP,
6568
column: SEXP,
69+
uri: SEXP,
6670
) -> anyhow::Result<SEXP> {
71+
let kind: String = RObject::view(uri).try_into()?;
72+
let kind = OpenEditorKind::from_str(&kind)?;
73+
6774
let params = OpenEditorParams {
6875
file: RObject::view(file).try_into()?,
6976
line: RObject::view(line).try_into()?,
7077
column: RObject::view(column).try_into()?,
78+
kind,
7179
};
7280

7381
let event = UiFrontendEvent::OpenEditor(params);

0 commit comments

Comments
 (0)