Skip to content

Commit ad03676

Browse files
committed
Do not put dots on operators
1 parent 8649995 commit ad03676

File tree

2 files changed

+25
-2
lines changed
  • app
    • gui/src/project-view/components/ComponentBrowser
    • rust-ffi/src

2 files changed

+25
-2
lines changed

app/gui/src/project-view/components/ComponentBrowser/input.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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-zA-Z]/.test(text) ?
288+
`${sourceNodeIdentifier.value}.${text}`
289+
: `${sourceNodeIdentifier.value} ${text}`
290+
: text
291+
)
286292
}
287293

288294
return proxyRefs({

app/rust-ffi/src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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]
4764
pub 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(""));

0 commit comments

Comments
 (0)