diff --git a/src/execute_request.jl b/src/execute_request.jl index 344e736d..f06c62b3 100644 --- a/src/execute_request.jl +++ b/src/execute_request.jl @@ -28,6 +28,11 @@ function run_cell_code(code) if startswith(code, "@@") lines = split(code, '\n') for line in lines + line = strip(line) + if length(line) <= 0 + line_no += 1 + continue + end startswith(line, "@@") || break mac_call = Meta.parse(line[nextind("abc", 0, 2):end]) @assert Meta.isexpr(mac_call, :macrocall) diff --git a/src/handlers.jl b/src/handlers.jl index a0e25a56..a2e0f5a4 100644 --- a/src/handlers.jl +++ b/src/handlers.jl @@ -7,10 +7,22 @@ using .CommManager parseok(s) = !Meta.isexpr(Meta.parse(s, raise=false), :error) function find_parsestart(code, cursorpos) s = firstindex(code) + in_macro_header = true while s < cursorpos + s_next = nextind(code, s) + if in_macro_header && s_next <= cursorpos && code[s:s_next] == "@@" + # Skip first '@' to pretend it's a normal macro for completion + s, s_next = s_next, nextind(code, s_next) + else + in_macro_header = false + end parseok(code[s:cursorpos]) && return s - s = nextind(code, s) - while s < cursorpos && code[s] ∉ ('\n','\r') + # Go to next line + s = s_next + while s < cursorpos && code[s] ∉ "\n\r" + s = nextind(code, s) + end + while s < cursorpos && code[s] ∈ "\n\r \t" s = nextind(code, s) end end