@@ -902,11 +902,11 @@ const superscript_regex = Regex("^\\\\\\^[" * join(isdigit(k) || isletter(k) ? "
902902
903903# Aux function to detect whether we're right after a using or import keyword
904904function 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 *)+$ "
907907
908908 # 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)
910910 if mod_import_match_simple != = nothing
911911 if mod_import_match_simple[1 ] == " using"
912912 return :using_module
@@ -915,7 +915,7 @@ function get_import_mode(s::String)
915915 end
916916 end
917917 # 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)
919919 if mod_import_match != = nothing
920920 if mod_import_match. captures[1 ] == " using"
921921 return :using_module
@@ -924,7 +924,7 @@ function get_import_mode(s::String)
924924 end
925925 end
926926 # 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)
928928 if name_import_match != = nothing
929929 if name_import_match[1 ] == " using"
930930 return :using_name
0 commit comments