Version: 2.0.3 and below (using KDE 3.5.10) OS: Linux Installed from: Ubuntu Packages With auto-complete environments on, when I type "\begin{env}<enter>", kile adds a "\end{env}" line, but _also_ adds a blank line after that. After using kile for six months, I haven't found a single situation where that blank line is desirable. It is particularly troublesome in a display math environment, because a blank line there results in an error. So anytime I do a cases, matrix, or other environment inside a math environment, I am _forced_ to remove this blank line, or my document won't even compile. I think this blank line should not be added, or at the very least, an option should be introduced to suppress it. Following the directions in this thread ( https://sourceforge.net/forum/message.php?msg_id=5791607 ), I built my own kile without this blank line behavior, and it works great. Kudos to the developers for being so responsive and helpful.
I think I found one situation where the old behaviour is wanted. Consider the following line: \begin{abstract} asdfsdf ^ there we cursor is at the ^ position. Hitting enter with "automatic environment closing" enabled and the additional new line: -------- \begin{abstract} \end{abstract} asdfsdf -------- and without the new line: -------- \begin{abstract} \end{abstract}asdfsdf -------- The latter case I think is not really what you expect. So my suggestion would be to check if the cursor is at the end of line before inserting "\end{}" and only add a newline after it if the cursors was not at the end of line.
The \[ \] pair (display math) is another case of this same behavior, not fixed by the code change in the discussion thread. And I agree that the current behavior is more appropriate in the case where Enter is hit mid-line.
Created attachment 48414 [details] Patch for not inserting blank line after autocompletion Patch based on http://sourceforge.net/projects/kile/forums/forum/292014/topic/2669855?message=5791607 for not inserting a blank line after autocompletion; against the current revision r1141173
As this bug is pending in the current revision (r1141173), I attached a patch for this, which is just an update of the one proposed in http://sourceforge.net/projects/kile/forums/forum/292014/topic/2669855?message=5791607. It now _does_ remove the blank line on \[ \] autocompletion, too. Regarding the current behavior for mid-line cases I have observed two points: 1. In many cases the text behind the auto-completed tag is place _in_ the completion, not after it. (e.g. "foo \[ bar" is replaced with "foo \[ bar \n\]" when Enter is hit after \[. 2. The insertion of just "\n" at the end of the auto-completed text is not correct, it has to be "indentation + \n", as without that, the current indentation is lost. I didn't have the time to figure out, how this could be done. So I suppose to use the attached patch and maybe add a check for mid-line execution where "indentation + \n" could be appended.
The patch looks ok to me, is it ok to commit?
Created attachment 83427 [details] Patch for not inserting blank line after autocompletion [version 2013-11-08]
Hey, unfortunately, this issue is still unfixed in the latest version of kile. I'm using my patch provided over 3 years ago since then and never encountered any problems with this. I'd thus be happy if it could be included future releases of kile. I attached an updated version of the patch against the current git revision of kile (as of 2013-11-08), which I'll also send to the developer mailing list (as requested on http://kile.sourceforge.net/developers.php). Best Regards, Felix
@Kile devs: This patch is around for 2 years now and was never committed. Is there any specific reason for this? :-) It's always better to simply a reject a patch instead of keeping it open for years.
Created attachment 91347 [details] Patch to make newline after environment completion optional I'm not sure about the placement of the config item (LaTeX/Environments), because it does not only affect the completion done by the item right above it, but also the completion configured at Kile/Complete.
@Kile devs, This behavior is still present and detracts from the work flow. The suggestion to make the new line only be created when the environment is auto completed mid line would be great, but at the very lease disabling it would be nice. This problem has apparently been around for a while, and doesn't appear to have been responded to. Thanks for the otherwise awesome LaTeX editor!
A possibly relevant merge request was started @ https://invent.kde.org/office/kile/-/merge_requests/51
Git commit 3e1c37661855d4845ca0bd54a8e7cda0cd6dccad by Michel Ludwig, on behalf of Kishore Gopalakrishnan. Committed on 22/10/2023 at 14:07. Pushed by mludwig into branch 'master'. Environment completion: only insert newline when necessary This change makes a newline to be inserted after \end{env} only if there was text to the right of the cursor when the user pressed enter. It also makes sure the newline respects the existing indentation. The special case of `\[...\]` is also handled. **Test cases:** In each case below, the pipe character is meant to denote the position of the cursor, not an actual character. Place the cursor as indicated (in insert mode) and press the Enter key on the keyboard. **1.** Before pressing Enter: ``` \begin{equation}| ``` After pressing Enter: ``` \begin{equation} | \end{equation} ``` **2.** Before pressing Enter: ``` \begin{align} \begin{split}| \end{align} ``` After pressing Enter: ``` \begin{align} \begin{split} | \end{split} \end{align} ``` **3.** Before pressing Enter: ``` \begin{equation}|abc123 ``` After pressing Enter: ``` \begin{equation} | \end{equation} abc123 ``` **4.** Before pressing Enter: ``` \begin{align} \begin{split}|abc123 \end{align} ``` After pressing Enter: ``` \begin{align} \begin{split} | \end{split} abc123 \end{align} ``` **5.** Before pressing Enter: ``` \[|abcasdf ``` After pressing Enter: ``` \[ | \] abcasdf ``` M +8 -2 src/editorextension.cpp https://invent.kde.org/office/kile/-/commit/3e1c37661855d4845ca0bd54a8e7cda0cd6dccad