diffposition

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCommentingRanges

func GetCommentingRanges(patch string, isBase bool) ([][2]int, error)

GetCommentingRanges determines which line ranges are valid for commenting For base file (left): only deleted lines are commentable For modified file (right): all changed lines are commentable

func MapNewPositionToOld

func MapNewPositionToOld(patch string, newLine int) (int, error)

MapNewPositionToOld maps a line number from the new file to the old file using the diff patch. Returns the old line number (1-based) or -1 if not found.

func MapOldPositionToNew

func MapOldPositionToNew(patch string, oldLine int) (int, error)

MapOldPositionToNew maps a line number from the old file to the new file using the diff patch. Returns the new line number (1-based) or -1 if not found.

Types

type CommentPosition

type CommentPosition struct {
	Line              int      // Current line number (1-based)
	OriginalLine      int      // Original line number (1-based)
	StartLine         int      // For multi-line comments
	EndLine           int      // For multi-line comments
	OriginalStartLine int      // For multi-line comments
	OriginalEndLine   int      // For multi-line comments
	DiffSide          DiffSide // Which side of the diff
	IsOutdated        bool     // Whether the comment is on outdated code
}

CommentPosition represents the position of a comment in a diff

func CalculateCommentPosition

func CalculateCommentPosition(line, originalLine int, diffHunk string, diffSide DiffSide) (*CommentPosition, error)

CalculateCommentPosition calculates the comment position from GitHub API data

type DiffSide

type DiffSide string

DiffSide represents which side of a diff a comment is on

const (
	DiffSideLeft  DiffSide = "LEFT"  // Original/base file
	DiffSideRight DiffSide = "RIGHT" // Modified/new file
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL