Sometimes I wish to use the \input{...} command when writing papers.
However, in TeXstudio, my editor of choice, this messes up the Structure Tree display on the left-hand side.
While I realise some people don't use this, I find it very helpful for quickly navigating---additionally, right-click on a section and it gives the option to add the \ref{sec:...}, which is helpful.
I include here an example. It doesn't compile since it needs an auxiliary file, but if it is pasted into TeXstudio, the issue is apparent. I have also included a picture showing what happens. In short, the \input{...} part is put on the highest tree-level.
Is this a known bug with a known fix?
Related: Using structural commands in \newcommand - structure messed up?
\documentclass[]{article}
\begin{document}
\section{Section 1}
\subsection{Subsection 1.1}
\input{some_code.tex}
\subsection{Subsection 1.2}
\section{Section 2}
\subsection{Subsection 2.1}
\subsection{Subsection 2.2}
\end{document}


relatedquestions. (Often it's easier to find stuff on Stack Exchange via the "related questions" than searching directly!) I have copied this answer below (giving credit to the original poster). – Sam OT Apr 14 '20 at 13:42