@@ -99,6 +99,7 @@ impl WorkspaceVariableDisplayValue {
99
99
CLOSXP => Self :: from_closure ( value) ,
100
100
ENVSXP => Self :: from_env ( value) ,
101
101
LANGSXP => Self :: from_language ( value) ,
102
+ CHARSXP => Self :: from_charsxp ( value) ,
102
103
_ if r_is_matrix ( value) => Self :: from_matrix ( value) ?,
103
104
RAWSXP | LGLSXP | INTSXP | REALSXP | STRSXP | CPLXSXP => Self :: from_default ( value) ?,
104
105
_ if r_is_s4 ( value) => Self :: from_s4 ( value) ?,
@@ -356,6 +357,10 @@ impl WorkspaceVariableDisplayValue {
356
357
Ok ( Self :: new ( display_value, false ) )
357
358
}
358
359
360
+ fn from_charsxp ( _: SEXP ) -> Self {
361
+ Self :: new ( String :: from ( "<CHARSXP>" ) , false )
362
+ }
363
+
359
364
fn from_default ( value : SEXP ) -> anyhow:: Result < Self > {
360
365
let formatted = FormattedVector :: new ( RObject :: from ( value) ) ?;
361
366
@@ -445,6 +450,11 @@ impl WorkspaceVariableDisplayType {
445
450
return Self :: from_class ( value, String :: from ( "S4" ) ) ;
446
451
}
447
452
453
+ // We can't check attributes of CHARSXP, so we just short-circuit here
454
+ if r_typeof ( value) == CHARSXP {
455
+ return Self :: simple ( String :: from ( "CHARSXP" ) ) ;
456
+ }
457
+
448
458
if r_is_simple_vector ( value) {
449
459
let display_type = match include_length {
450
460
true => match r_vec_is_single_dimension_with_single_value ( value) {
@@ -2078,4 +2088,18 @@ mod tests {
2078
2088
assert ! ( vars[ 0 ] . display_value. starts_with( "<S4 class" ) , ) ;
2079
2089
} )
2080
2090
}
2091
+
2092
+ #[ test]
2093
+ fn test_charsxp ( ) {
2094
+ r_task ( || {
2095
+ let env = Environment :: new_empty ( ) . unwrap ( ) ;
2096
+ let value = harp:: parse_eval_base ( r#"rlang:::chr_get("foo", 0L)"# ) . unwrap ( ) ;
2097
+ env. bind ( "x" . into ( ) , & value) ;
2098
+
2099
+ let path = vec ! [ ] ;
2100
+ let vars = PositronVariable :: inspect ( env. into ( ) , & path) . unwrap ( ) ;
2101
+ assert_eq ! ( vars. len( ) , 1 ) ;
2102
+ assert_eq ! ( vars[ 0 ] . display_value, "<CHARSXP>" ) ;
2103
+ } )
2104
+ }
2081
2105
}
0 commit comments