کدتون رو اگه توی ویرایشگر باز کنیم، به این صورت نمایش داده میشه:

همونطور که میبینین، خط ۲۳ در ادامه خط ۲۲ نیست و با یه Enter به خط بعدی منتقل شده و بنابراین برای خودش یه خط جداگونه حساب میشه. به خاطر همین، بسته listings اون رو یه خط جدا حساب کرده و براش شماره گذاشته. به عبارت دیگه رفتار بسته listings کاملاً درست و طبیعیه. اگه میخواین شماره نخوره، باید به این صورت تغییرش بدین:

بهروزرسانی
من وقتی کد
\documentclass[12pt]{article}
\usepackage[localize]{xepersian}
\settextfont[Scale=1.1]{Yas}
\usepackage[margin=2.5cm]{geometry}
\usepackage{listings}
\lstset{
language=Python, %
frame=single, %
keywordstyle=\bfseries,
numbers=left, %
numberstyle=\footnotesize, %
showstringspaces=false , %
breaklines, %
basicstyle=\ttfamily, %
}
\begin{document}
\begin{latin}
\begin{lstlisting}
x=1
print(x+1)
print('This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.')
print([1,2,3,4],
[`ali', `amir', `ava', `friba'])
\end{lstlisting}
\end{latin}
\end{document}
رو اجرا میکنم، خروجی پایین رو میگیرم. همونطور که میبینین، هر چند خط که باشه، تا زمانی که Enter نزنم، کل اون خط رو ۱ خط در نظر میگیره و بنابراین توی خروجی فقط خط اول شماره میخوره:
