Skip to content

Commit

Permalink
Add completion for cell macros
Browse files Browse the repository at this point in the history
  • Loading branch information
cduck committed Jul 20, 2020
1 parent e9e9587 commit 9640789
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/execute_request.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 14 additions & 2 deletions src/handlers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9640789

Please sign in to comment.