File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
gui/src/project-view/components/ComponentBrowser Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -282,7 +282,13 @@ export function useComponentBrowserInput(
282
282
}
283
283
284
284
function applySourceNode ( text : string ) {
285
- return sourceNodeIdentifier . value ? `${ sourceNodeIdentifier . value } .${ text } ` : text
285
+ return (
286
+ sourceNodeIdentifier . value ?
287
+ / ^ [ a - z A - Z ] / . test ( text ) ?
288
+ `${ sourceNodeIdentifier . value } .${ text } `
289
+ : `${ sourceNodeIdentifier . value } ${ text } `
290
+ : text
291
+ )
286
292
}
287
293
288
294
return proxyRefs ( {
Original file line number Diff line number Diff line change @@ -43,6 +43,23 @@ pub fn is_ident_or_operator(code: &str) -> u32 {
43
43
}
44
44
}
45
45
46
+ #[ wasm_bindgen]
47
+ pub fn is_ident_or_operator ( code : & str ) -> u32 {
48
+ let parsed = enso_parser:: lexer:: run ( code) ;
49
+ if parsed. internal_error . is_some ( ) {
50
+ return 0 ;
51
+ }
52
+ let token = match & parsed. value [ ..] {
53
+ [ token] => token,
54
+ _ => return 0 ,
55
+ } ;
56
+ match & token. variant {
57
+ enso_parser:: syntax:: token:: Variant :: Ident ( _) => 1 ,
58
+ enso_parser:: syntax:: token:: Variant :: Operator ( _) => 2 ,
59
+ _ => 0 ,
60
+ }
61
+ }
62
+
46
63
#[ wasm_bindgen]
47
64
pub fn is_numeric_literal ( code : & str ) -> bool {
48
65
let parsed = PARSER . with ( |parser| parser. parse_block ( code) ) ;
@@ -74,7 +91,7 @@ mod tests {
74
91
use super :: * ;
75
92
76
93
#[ test]
77
- fn test_is_ident_or_operator ( ) {
94
+ fn test_is_numeric_literal ( ) {
78
95
assert ! ( is_numeric_literal( "1234" ) ) ;
79
96
assert ! ( is_numeric_literal( "-1234" ) ) ;
80
97
assert ! ( !is_numeric_literal( "" ) ) ;
You can’t perform that action at this time.
0 commit comments