% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/editor.R
\name{gather_context}
\alias{gather_context}
\title{Collect N lines of surrounding code above the cursor}
\usage{
gather_context(ctx, row, n = 30)
}
\arguments{
\item{ctx}{An \code{rstudio_editor_context} object.}

\item{row}{Integer.  1-based row of the comment line (context is taken from
rows \code{max(1, row - n)} to \code{row - 1}).}

\item{n}{Integer.  Maximum number of context lines (default \code{30}).}
}
\value{
A single character string (may be \code{""} if \code{row == 1}).
}
\description{
Returns a character string containing the \code{n} lines of source code
immediately above the comment line, joined by newlines.  This is sent to the
LLM as context so that it can infer variable names, existing code style, and
already-loaded packages.
}
\keyword{internal}
