Skip to content

Commit 1e65c42

Browse files
authored
Merge pull request #351 from julia-vscode/sp/fix-semiseminewline-ncat
Fix [1;;\n2] parsing
2 parents a666581 + d739c86 commit 1e65c42

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/components/lists.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ function parse_array(ps::ParseState, isref = false)
100100
end
101101
end
102102

103-
binding_power(ps) =
103+
binding_power(ps, nl = true) =
104104
if kindof(ps.ws) == SemiColonWS
105-
-count_semicolons(ps)
105+
-count_semicolons(ps, nl)
106106
elseif kindof(ps.ws) == NewLineWS
107107
-1
108108
elseif kindof(ps.ws) == WS
@@ -115,6 +115,7 @@ function parse_array_outer(ps::ParseState, trivia, isref)
115115
args_list = EXPR[]
116116
trivia_bp = Int[]
117117
min_bp = 0
118+
max_bp = -typemax(Int)
118119
is_start = true
119120
while kindof(ps.nt) !== Tokens.RSQUARE && kindof(ps.nt) !== Tokens.ENDMARKER
120121
a = @nocloser ps :newline @nocloser ps :newline @closesquare ps @closer ps :insquare @closer ps :ws @closer ps :wsop @closer ps :comma parse_expression(ps)
@@ -157,8 +158,9 @@ function parse_array_outer(ps::ParseState, trivia, isref)
157158

158159
push!(args_list, a)
159160

160-
bp = binding_power(ps)
161+
bp = binding_power(ps, max_bp == 0)
161162
bp < min_bp && (min_bp = bp)
163+
bp > max_bp && (max_bp = bp)
162164
if bp <= 0
163165
push!(trivia_bp, bp)
164166
end

test/parser.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ end
525525
@test "t[x;;]" |> test_expr
526526
@test "t[x;; y;; z]" |> test_expr
527527
@test "t[x;;; y;;;z]" |> test_expr
528+
@test "t[x;;\ny]" |> test_expr
529+
@test "t[x y;;\nz a]" |> test_expr
528530
end
529531
end
530532

0 commit comments

Comments
 (0)