\documentclass{report}
\usepackage{hyperref}
% WARNING: THIS SHOULD BE MODIFIED DEPENDING ON THE LETTER/A4 SIZE
\oddsidemargin 0cm
\evensidemargin 0cm
\marginparsep 0cm
\marginparwidth 0cm
\parindent 0cm
\textwidth 16.5cm

\ifpdf
  \usepackage[pdftex]{graphicx}
\else
  \usepackage[dvips]{graphicx}
\fi

% definitons for warning and note tag
\usepackage[most]{tcolorbox}
\newtcolorbox{tcbwarning}{
 breakable,
 enhanced jigsaw,
 top=0pt,
 bottom=0pt,
 titlerule=0pt,
 bottomtitle=0pt,
 rightrule=0pt,
 toprule=0pt,
 bottomrule=0pt,
 colback=white,
 arc=0pt,
 outer arc=0pt,
 title style={white},
 fonttitle=\color{black}\bfseries,
 left=8pt,
 colframe=red,
 title={Warning:},
}
\newtcolorbox{tcbnote}{
 breakable,
 enhanced jigsaw,
 top=0pt,
 bottom=0pt,
 titlerule=0pt,
 bottomtitle=0pt,
 rightrule=0pt,
 toprule=0pt,
 bottomrule=0pt,
 colback=white,
 arc=0pt,
 outer arc=0pt,
 title style={white},
 fonttitle=\color{black}\bfseries,
 left=8pt,
 colframe=yellow,
 title={Note:},
}

\begin{document}
% special variable used for calculating some widths.
\newlength{\tmplength}
\chapter{Unit ok{\_}longcode{\_}indentation}
\section{Overview}
\begin{description}
\item[\texttt{Foo1}]
\item[\texttt{Foo2}]
\item[\texttt{Foo3}]
\item[\texttt{Foo4}]
\item[\texttt{Foo5}]
\item[\texttt{Foo6}]
\item[\texttt{Foo7}]
\end{description}
\section{Functions and Procedures}
\subsection*{Foo1}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
procedure Foo1;\end{ttfamily}


\end{flushleft}
\par
\item[\textbf{Description}]
Should cut nothing:

\texttt{one\\\nopagebreak[3]
~~two\\\nopagebreak[3]
~~~~three\\
}

\end{list}
\subsection*{Foo2}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
procedure Foo2;\end{ttfamily}


\end{flushleft}
\par
\item[\textbf{Description}]
Should cut 4 spaces:

\texttt{\\\nopagebreak[3]
one\\\nopagebreak[3]
two\\\nopagebreak[3]
three\\
}

\end{list}
\subsection*{Foo3}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
procedure Foo3;\end{ttfamily}


\end{flushleft}
\par
\item[\textbf{Description}]
Should cut 2 spaces:

\texttt{\\\nopagebreak[3]
~~one\\\nopagebreak[3]
two\\\nopagebreak[3]
~~three\\
}

\end{list}
\subsection*{Foo4}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
procedure Foo4;\end{ttfamily}


\end{flushleft}
\par
\item[\textbf{Description}]
Should cut nothing (there's a tab here):

\texttt{\\\nopagebreak[3]
~~~~one\\\nopagebreak[3]
	two\\\nopagebreak[3]
~~~~three\\
}

\end{list}
\subsection*{Foo5}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
procedure Foo5;\end{ttfamily}


\end{flushleft}
\par
\item[\textbf{Description}]
Should cut tab + 2 spaces:

\texttt{\\\nopagebreak[3]
one\\\nopagebreak[3]
~~two\\\nopagebreak[3]
three\\
}

\end{list}
\subsection*{Foo6}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
procedure Foo6;\end{ttfamily}


\end{flushleft}
\par
\item[\textbf{Description}]
Should cut 4 spaces (there's trailing whitespace in 1st lines here, that should be ignored):

\texttt{\\\nopagebreak[3]
~~~~~~~~~~~~~~~~~\\\nopagebreak[3]
~~~~~~~~~~~~~~~~~~\\\nopagebreak[3]
one\\
}

\end{list}
\subsection*{Foo7}
\begin{list}{}{
\settowidth{\tmplength}{\textbf{Description}}
\setlength{\itemindent}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\leftmargin}{\evensidemargin}
\addtolength{\leftmargin}{\tmplength}
\settowidth{\labelsep}{X}
\addtolength{\leftmargin}{\labelsep}
\setlength{\labelwidth}{\tmplength}
}
\begin{flushleft}
\item[\textbf{Declaration}\hfill]
\begin{ttfamily}
procedure Foo7;\end{ttfamily}


\end{flushleft}
\par
\item[\textbf{Description}]
Should cut 4 spaces (empty line doesn't shorten IndentationPrefix):

\texttt{\\\nopagebreak[3]
}\textbf{if}\texttt{~something~}\textbf{then}\texttt{\\\nopagebreak[3]
}\textbf{begin}\texttt{\\\nopagebreak[3]
~~\textit{//~empty~line~below}\\\nopagebreak[3]
\\\nopagebreak[3]
}\textbf{end}\texttt{;\\
}

\end{list}
\end{document}
