@@ -902,11 +902,11 @@ const superscript_regex = Regex("^\\\\\\^[" * join(isdigit(k) || isletter(k) ? "
902
902
903
903
# Aux function to detect whether we're right after a using or import keyword
904
904
function get_import_mode (s:: String )
905
- # allow all of these to start with leading whitespace and macros like @eval and @eval(
906
- # ^\s*(?:@\w+\s*(?:\(\s*)?)?
905
+ # allow all of these to start with leading whitespace and potentially multiple macros like @eval and @eval(
906
+ prefix = raw " ^\s *(?:@\w +\s *(?:\(\s *)?\s *)+ "
907
907
908
908
# match simple cases like `using |` and `import |`
909
- mod_import_match_simple = match (r" ^ \s *(?:@ \w + \s *(?: \(\s *)?)? \ b (using|import)\s *$" , s)
909
+ mod_import_match_simple = match (Regex (prefix * raw " \ b (using|import)\s *$" ) , s)
910
910
if mod_import_match_simple != = nothing
911
911
if mod_import_match_simple[1 ] == " using"
912
912
return :using_module
@@ -915,7 +915,7 @@ function get_import_mode(s::String)
915
915
end
916
916
end
917
917
# match module import statements like `using Foo|`, `import Foo, Bar|` and `using Foo.Bar, Baz, |`
918
- mod_import_match = match (r" ^ \s *(?:@ \w + \s *(?: \(\s *)?)? \ b (using|import)\s +([\w\. ]+(?:\s *,\s *[\w\. ]+)*),?\s *$" , s)
918
+ mod_import_match = match (Regex (prefix * raw " \ b (using|import)\s +([\w\. ]+(?:\s *,\s *[\w\. ]+)*),?\s *$" ) , s)
919
919
if mod_import_match != = nothing
920
920
if mod_import_match. captures[1 ] == " using"
921
921
return :using_module
@@ -924,7 +924,7 @@ function get_import_mode(s::String)
924
924
end
925
925
end
926
926
# now match explicit name import statements like `using Foo: |` and `import Foo: bar, baz|`
927
- name_import_match = match (r" ^ \s *(?:@ \w + \s *(?: \(\s *)?)? \ b (using|import)\s +([\w\. ]+)\s *:\s *([\w @!\s ,]+)$" , s)
927
+ name_import_match = match (Regex (prefix * raw " \ b (using|import)\s +([\w\. ]+)\s *:\s *([\w @!\s ,]+)$" ) , s)
928
928
if name_import_match != = nothing
929
929
if name_import_match[1 ] == " using"
930
930
return :using_name
0 commit comments