Bug 322654 - Auto-completing a indented \begin{env} with trailing text does not work as expected
Summary: Auto-completing a indented \begin{env} with trailing text does not work as ex...
Status: RESOLVED FIXED
Alias: None
Product: kile
Classification: Applications
Component: editor (show other bugs)
Version: 2.1.3
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Michel Ludwig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-21 14:41 UTC by Narthana Epa
Modified: 2023-07-01 06:31 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Partial fix for the tabbed indetation. (460 bytes, patch)
2014-01-05 21:33 UTC, Narthana Epa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Narthana Epa 2013-07-21 14:41:41 UTC
Suppose one wishes to complete the following:
				\begin{env}|Stuff that should be in the environment
where the enter key is pressed at the position of the pipe. Then, depending on the indenting of the initial line, the output is something like:
				\begin{env}Stuff that s
				 
				\end{env}hould be in the environment

whereas IMO it should be
				\begin{env}
			 		Stuff that should be in the environment
				\end{env}

Reproducible: Always

Steps to Reproduce:
1. Type the stated text into the editor with code completion turned on.
2. Press enter with the caret at the stated position.
Actual Results:  
				\begin{env}Stuff that s
				 
				\end{env}hould be in the environment


Expected Results:  
				\begin{env}
			 		Stuff that should be in the environment
				\end{env}

It also happens for completion of "\[".
It is arguable that the expected result should be
				\begin{env}
			 		
				\end{env}Stuff that should be in the environment
which is the behaviour if there is no indentation.
Comment 1 Narthana Epa 2013-07-21 14:57:52 UTC
Also present in 2.9.60.

It actually seems to only occur when tabs are used as indentation characters.

Also I erroneously stated that the actually result when there is no indentation (or only spaces are used for indentation) is
				\begin{env}
			 		
				\end{env}Stuff that should be in the environment
when it is actually
				\begin{env}
			 		
				\end{env}
				Stuff that should be in the environment
Comment 2 Narthana Epa 2013-07-21 14:59:54 UTC
Similarly the actual result is 
				\begin{env}Stuff that s
				 
				\end{env}
				hould be in the environment
Comment 3 Narthana Epa 2014-01-05 21:33:36 UTC
Created attachment 84471 [details]
Partial fix for the tabbed indetation.

This seems to fix the case of tabbed indentation causing the the auto-completion of:
      \begin{env}|asdfsadf
to
       \begin{env}|asd
fsadf
Comment 4 Andrew Crouthamel 2018-11-11 04:29:25 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 5 Andrew Crouthamel 2018-11-21 04:31:42 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Kishore Gopalakrishnan 2022-09-18 09:52:21 UTC
Still reproducible with 

kile 2.9.93
Operating System: Arch Linux
KDE Plasma Version: 5.25.90
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 5.15.68-1-lts (64-bit)
Graphics Platform: X11
Comment 7 Michel Ludwig 2023-07-01 06:31:26 UTC
Git commit 7e142b1bec7de8a429ef401cc551797b2fbe61df by Michel Ludwig, on behalf of Kishore Gopalakrishnan.
Committed on 01/07/2023 at 06:31.
Pushed by mludwig into branch 'master'.

Environment completion: don't use virtual cursor position

What we actually need here is the real cursor position (where tab is
counted as one character) rather than the virtual cursor position (where
tab can count as multiple characters depending on the user's config).
This commit makes sure that \end{env} is inserted in the right place
even when the user uses tabs for indentation.

M  +1    -1    src/editorextension.cpp

https://invent.kde.org/office/kile/-/commit/7e142b1bec7de8a429ef401cc551797b2fbe61df