@@ -232,6 +232,67 @@ describe("lib.git.log.parse", function()
232
232
" " ,
233
233
" ---@param selection Selection" ,
234
234
},
235
+ pager_contents = {
236
+ {
237
+ " ---@param first_line number" ,
238
+ " ---@param last_line number" ,
239
+ " ---@param partial boolean" ,
240
+ " ----@return SelectedHunk[],string[]" ,
241
+ " +---@return SelectedHunk[]" ,
242
+ " function M.get_item_hunks(item, first_line, last_line, partial)" ,
243
+ " if item.folded or item.hunks == nil then" ,
244
+ " - return {}, {}" ,
245
+ " + return {}" ,
246
+ " end" ,
247
+ " " ,
248
+ " local hunks = {}" ,
249
+ " - local lines = {}" ,
250
+ " " ,
251
+ " for _, h in ipairs(item.hunks) do" ,
252
+ " - -- Transform to be relative to the current item/file" ,
253
+ " - local first_line = first_line - item.first" ,
254
+ " - local last_line = last_line - item.first" ,
255
+ " -" ,
256
+ " - if h.diff_from <= last_line and h.diff_to >= first_line then" ,
257
+ " - -- Relative to the hunk" ,
258
+ " + if h.first <= last_line and h.last >= first_line then" ,
259
+ " local from, to" ,
260
+ " +" ,
261
+ " if partial then" ,
262
+ " - from = h.diff_from + math.max(first_line - h.diff_from, 0)" ,
263
+ " - to = math.min(last_line, h.diff_to)" ,
264
+ " + local length = last_line - first_line" ,
265
+ " + from = h.diff_from + math.max((first_line - item.first) - h.diff_from, 0)" ,
266
+ " + to = from + length" ,
267
+ " else" ,
268
+ " from = h.diff_from + 1" ,
269
+ " to = h.diff_to" ,
270
+ " end" ,
271
+ " " ,
272
+ " local hunk_lines = {}" ,
273
+ " -" ,
274
+ " for i = from, to do" ,
275
+ " table.insert(hunk_lines, item.diff.lines[i])" ,
276
+ " end" ,
277
+ },
278
+ {
279
+ " setmetatable(o, o)" ,
280
+ " " ,
281
+ " table.insert(hunks, o)" ,
282
+ " -" ,
283
+ " - for i = from, to do" ,
284
+ " - table.insert(lines, item.diff.lines[i + h.diff_from])" ,
285
+ " - end" ,
286
+ " end" ,
287
+ " end" ,
288
+ " " ,
289
+ " - return hunks, lines" ,
290
+ " + return hunks" ,
291
+ " end" ,
292
+ " " ,
293
+ " ---@param selection Selection" ,
294
+ },
295
+ },
235
296
stats = {
236
297
additions = 0 ,
237
298
deletions = 0 ,
@@ -320,6 +381,19 @@ describe("lib.git.log.parse", function()
320
381
' of this software and associated documentation files (the "Software"), to deal' ,
321
382
" in the Software without restriction, including without limitation the rights" ,
322
383
},
384
+ pager_contents = {
385
+ {
386
+ " MIT License" ,
387
+ " " ,
388
+ " +hello" ,
389
+ " Copyright (c) 2020 TimUntersberger" ,
390
+ " " ,
391
+ " +world" ,
392
+ " Permission is hereby granted, free of charge, to any person obtaining a copy" ,
393
+ ' of this software and associated documentation files (the "Software"), to deal' ,
394
+ " in the Software without restriction, including without limitation the rights" ,
395
+ },
396
+ },
323
397
stats = {
324
398
additions = 0 ,
325
399
deletions = 0 ,
0 commit comments