feat: add expandable diff excerpts with configurable context

This commit is contained in:
2026-10-11 01:45:13 +02:00
parent 5e0700bb8c
commit 704dce2539
8 changed files with 590 additions and 21 deletions
+30 -1
View File
@@ -16,6 +16,8 @@ module Vamp
@file_picker_view = "tree"
@file_explorer_view = "tree"
@clipboard_mode = "system"
@diff_context_lines = 10
@diff_expand_lines = 15
end
# @param path [String] relative to the configuration file
@@ -60,6 +62,18 @@ module Vamp
@clipboard_mode = nonempty_string!(mode, "clipboard mode")
end
# @param lines [Integer] nonnegative context lines around each diff change
# @return [Integer]
def diff_context_lines=(lines)
@diff_context_lines = diff_line_count!(lines, "diff_context_lines", 0)
end
# @param lines [Integer] positive lines revealed per diff expansion
# @return [Integer]
def diff_expand_lines=(lines)
@diff_expand_lines = diff_line_count!(lines, "diff_expand_lines", 1)
end
# @return [Module<Vamp::Core>] frozen namespace with catalog-generated Action methods
def core
Core
@@ -90,11 +104,26 @@ module Vamp
def response
{ "version" => 1, "type" => "config", "plugins" => @plugins, "lsp" => lsp_options, "bindings" => @bindings,
"leader" => @leader, "file_explorer_side" => @file_explorer_side, "file_picker_view" => @file_picker_view,
"file_explorer_view" => @file_explorer_view, "clipboard_mode" => @clipboard_mode }
"file_explorer_view" => @file_explorer_view, "clipboard_mode" => @clipboard_mode,
"diff_context_lines" => @diff_context_lines, "diff_expand_lines" => @diff_expand_lines }
end
private
# @param value [Integer]
# @param label [String]
# @param minimum [Integer]
# @return [Integer]
def diff_line_count!(value, label, minimum)
raise TypeError, "#{label} must be an Integer" unless value.is_a?(Integer)
maximum = (1 << 64) - 1
unless value.between?(minimum, maximum)
raise ArgumentError, "#{label} must be between #{minimum} and #{maximum}"
end
value
end
# @param value [String]
# @param label [String]
# @return [String]