diff --git a/src/command_line.jl b/src/command_line.jl index d84a560..dd55449 100644 --- a/src/command_line.jl +++ b/src/command_line.jl @@ -58,7 +58,6 @@ function _redraw_cmd_line!(pagerd::Pager) elseif mode == :searching active_search_match_id = pagerd.active_search_match_id - search_matches = pagerd.search_matches num_matches = pagerd.num_matches # Check if there are matches. diff --git a/src/pager.jl b/src/pager.jl index a7f7b85..cbc0cfe 100644 --- a/src/pager.jl +++ b/src/pager.jl @@ -181,7 +181,6 @@ function _pager_key_process!(pagerd::Pager, k::Keystroke) visual_mode = pagerd.visual_mode visual_mode_line = pagerd.visual_mode_line - redraw = false event = nothing key = (k.value, k.alt, k.ctrl, k.shift) action = get(_KEYBINDINGS, key, nothing) @@ -486,7 +485,6 @@ end # Process the event in `pagerd`. If this function return `false`, the application must exit. function _pager_event_process!(pagerd::Pager) event = pagerd.event - lines = pagerd.lines # For EOT (^D), we will implement two types of "quit" action. If we are in searching # mode, exit it. If not, quit the pager. @@ -536,7 +534,7 @@ function _pager_event_process!(pagerd::Pager) ) frozen_rows = tryparse(Int, cmd_input; base = 10) - if (frozen_rows == nothing) && !isempty(cmd_input) + if isnothing(frozen_rows) && !isempty(cmd_input) _print_cmd_message!( pagerd, "Invalid data!"; @@ -544,7 +542,7 @@ function _pager_event_process!(pagerd::Pager) ) _jlgetch(pagerd.term.in_stream) else - if frozen_rows != nothing + if !isnothing(frozen_rows) pagerd.frozen_rows = max(0, frozen_rows) pagerd.start_row = max(pagerd.start_row, frozen_rows + 1) pagerd.visual_mode_line = 1 @@ -556,14 +554,14 @@ function _pager_event_process!(pagerd::Pager) ) frozen_columns = tryparse(Int, cmd_input; base = 10) - if (frozen_columns == nothing) && !isempty(cmd_input) + if isnothing(frozen_columns) && !isempty(cmd_input) _print_cmd_message!( pagerd, "Invalid data!"; crayon = crayon"red bold" ) _jlgetch(pagerd.term.in_stream) - elseif frozen_columns != nothing + elseif !isnothing(frozen_columns) pagerd.frozen_columns = max(0, frozen_columns) pagerd.start_column = max(pagerd.start_column, frozen_columns + 1) end @@ -578,15 +576,15 @@ function _pager_event_process!(pagerd::Pager) ) title_rows = tryparse(Int, cmd_input; base = 10) - if (title_rows == nothing) && !isempty(cmd_input) + if isnothing(title_rows) && !isempty(cmd_input) _print_cmd_message!( pagerd, "Invalid data!"; crayon = crayon"red bold" ) _jlgetch(pagerd.term.in_stream) - else - title_rows != nothing && (pagerd.title_rows = max(0, title_rows)) + elseif !isnothing(title_rows) + pagerd.title_rows = max(0, title_rows) end _request_redraw!(pagerd) diff --git a/src/repl.jl b/src/repl.jl index dd18803..e85eb8f 100644 --- a/src/repl.jl +++ b/src/repl.jl @@ -225,12 +225,12 @@ function _tp_mode_do_cmd(repl::REPL.AbstractREPL, input::String) is_error = false # Loop through the lines. - @inbounds for i in 1:length(lines) + @inbounds for i in eachindex(lines) cmd *= lines[i] * "\n" ast = Base.parse_input_line(cmd) # If the command is incomplete, we need to wait for another line. - ast !== nothing && ast.head == :incomplete && continue + !isnothing(ast) && ast.head == :incomplete && continue # We will use `REPL.eval_with_backend` to evaluate the expression. This function # returns two values: the object returned by the expression, and a boolean value diff --git a/src/search.jl b/src/search.jl index 0214600..81e3114 100644 --- a/src/search.jl +++ b/src/search.jl @@ -7,13 +7,10 @@ # Change the active matches in `pagerd`. If `forward` is `true`, the search is performed # forward. Otherwise, it is performed backwards. function _change_active_match!(pagerd::Pager, forward::Bool = true) - search_matches = pagerd.search_matches active_search_match_id = pagerd.active_search_match_id num_matches = pagerd.num_matches - if num_matches == 0 - active_number_match = 0 - else + if num_matches != 0 # Activate the next match according to the user preference. if forward active_search_match_id += 1 diff --git a/src/view.jl b/src/view.jl index 39360c0..4ab4ed2 100644 --- a/src/view.jl +++ b/src/view.jl @@ -15,7 +15,6 @@ function _view!(pagerd::Pager) frozen_columns = pagerd.frozen_columns frozen_rows = pagerd.frozen_rows lines = pagerd.lines - num_lines = pagerd.num_lines search_matches = pagerd.search_matches show_ruler = pagerd.show_ruler start_column = pagerd.start_column