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(
282282 }
283283
284284 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+ )
286292 }
287293
288294 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 {
4343 }
4444}
4545
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+
4663#[ wasm_bindgen]
4764pub fn is_numeric_literal ( code : & str ) -> bool {
4865 let parsed = PARSER . with ( |parser| parser. parse_block ( code) ) ;
@@ -74,7 +91,7 @@ mod tests {
7491 use super :: * ;
7592
7693 #[ test]
77- fn test_is_ident_or_operator ( ) {
94+ fn test_is_numeric_literal ( ) {
7895 assert ! ( is_numeric_literal( "1234" ) ) ;
7996 assert ! ( is_numeric_literal( "-1234" ) ) ;
8097 assert ! ( !is_numeric_literal( "" ) ) ;
You can’t perform that action at this time.
0 commit comments