From a6ab136b72e473e568ba36abdf29435811ebbadb Mon Sep 17 00:00:00 2001 From: daviehh <25255906+daviehh@users.noreply.github.com> Date: Sun, 14 Jun 2020 10:49:54 -0400 Subject: [PATCH 1/2] fixing transpose expressions issue #200 --- src/BracketInserter.jl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/BracketInserter.jl b/src/BracketInserter.jl index 1577177..87417c0 100644 --- a/src/BracketInserter.jl +++ b/src/BracketInserter.jl @@ -33,6 +33,14 @@ function peek(b::IOBuffer) return c end +# when we should not close the bracket +function no_closing_bracket(left_peek, v) + # left_peek == v: we already have an open quote immediately before (triple quote) + # regex is for transposing calls: issue #200 + # regex: immediately after letter/_: \w or closing array bracket \] + left_peek == v || (v == '\'' && occursin(r"\w|\]", string(left_peek))) +end + const AUTOMATIC_BRACKET_MATCH = Ref(!Sys.iswindows()) enable_autocomplete_brackets(v::Bool) = AUTOMATIC_BRACKET_MATCH[] = v @@ -105,8 +113,7 @@ function insert_into_keymap!(D::Dict) # Next char is the quote symbol so just move right if !eof(b) && peek(b) == v edit_move_right(b) - # we already have an open quote immediately before (triple quote) - elseif position(b) > 0 && leftpeek(b) == v + elseif position(b) > 0 && no_closing_bracket(leftpeek(b), v) edit_insert(b, v) else edit_insert(b, v) From 92b828a16c8dbb681ea23429a89496b4d7c930a0 Mon Sep 17 00:00:00 2001 From: daviehh <25255906+daviehh@users.noreply.github.com> Date: Sun, 14 Jun 2020 12:20:24 -0400 Subject: [PATCH 2/2] no regex --- src/BracketInserter.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BracketInserter.jl b/src/BracketInserter.jl index 87417c0..e835cc1 100644 --- a/src/BracketInserter.jl +++ b/src/BracketInserter.jl @@ -36,9 +36,9 @@ end # when we should not close the bracket function no_closing_bracket(left_peek, v) # left_peek == v: we already have an open quote immediately before (triple quote) - # regex is for transposing calls: issue #200 - # regex: immediately after letter/_: \w or closing array bracket \] - left_peek == v || (v == '\'' && occursin(r"\w|\]", string(left_peek))) + # tr_expr is for transposing calls: issue #200 + tr_expr = isletter(left_peek) || isnumeric(left_peek) || left_peek == '_' || left_peek == ']' + left_peek == v || (v == '\'' && tr_expr) end const AUTOMATIC_BRACKET_MATCH = Ref(!Sys.iswindows())