Skip to content

Commit efdf5b7

Browse files
committed
refactor: simplify checking if suggestion has changed
1 parent e6931e0 commit efdf5b7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lua/gitlab/actions/suggestions.lua

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ local create_autocommands = function(
516516
imply_local,
517517
opts
518518
)
519-
local last_line, last_suggestion = suggestions[1].note_start_linenr, suggestions[1]
519+
local last_line = suggestions[1].note_start_linenr
520520

521521
---Update the suggestion buffer if the selected suggestion changes in the Comment buffer.
522522
local update_suggestion_buffer = function()
@@ -527,16 +527,11 @@ local create_autocommands = function(
527527
local suggestion = List.new(suggestions):find(function(sug)
528528
return current_line <= sug.note_end_linenr
529529
end)
530-
local old_buffer_text = u.get_buffer_text(suggestion_buf)
531-
if
532-
not suggestion
533-
or suggestion == last_suggestion
534-
or old_buffer_text == table.concat(suggestion.full_text, "\n")
535-
then
530+
if not suggestion or u.get_buffer_text(suggestion_buf) == table.concat(suggestion.full_text, "\n") then
536531
return
537532
end
538533
set_buffer_lines(suggestion_buf, suggestion.full_text, imply_local)
539-
last_line, last_suggestion = current_line, suggestion
534+
last_line = current_line
540535
refresh_signs(suggestion, note_buf)
541536
end
542537

0 commit comments

Comments
 (0)