Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## #625 auto completion bug

None
open
nobody
None
5*
2013-05-27
2012-11-07
Thiago
No

The auto completion for the command  is strange. For example, if I type $ I get \[$ with the cursor on the middle. That is great and useful. Then if I start to type a command (for example, \alpha) and press RETURN to auto complete, OK, I get $\alpha$.

But if the command is to short so that it is faster to type it completely (\nu for example) then I get $\nu] that is, the right backslash is deleted by the new inserted command. Any idea how to solve this? I'm using TeXstudio 2.5 (SVN 3337M). Thanks. ## Discussion • Tim Hoffmann 2012-11-07 Well, that is intended, at least partly. In order not to interrupt the flow of writing, TXS checks if you are re-typing an auto-inserted bracket and then moves the cursor over it instead of inserting it a second time. Otherwise you would have to move your hand to the arrow keys or use the mouse to get past the auto-inserted bracket. This works perfect for single-char brackets like }. In the case of $ we cannot determine if you want to start closing the bracket or if you want to start another commad by typing \.

In theory it might be possible to recognize this later when you typed \n and insert the slash again, i.e.
$|$
type \ -> $\|] alternative a) type ] -> \[$|

alternative b)
type n -> $\n|$

But I'm not into the code of the completer. So I cannot comment if this could be implemented with reasonable effort. One of the other developers would have to comment on this.

Anyway, the bracket auto-insertion is transparent for typing the whole string $\nu$. So simply keep typing and ignore the improper intermediate state.

Last edit: Tim Hoffmann 2012-11-07

• Thiago
2012-11-07

Dear Hoffmann, thanks for your attention. Sorry, but I didn't understand your final suggestion. If I try the option b I lost the backslash for the right bracket, that is:
$|$ -> $\|] -> \[\n|] In my opinion I guess that with the auto-completion for \[$ turned on it is clear that if I type \ it means that I really want a second backslash inside the brackets, so it is not a good idea for TXS just move the cursor one position to right.

Best wishes.

• Tim Hoffmann
2012-11-07

Alternative b) is not implemented. It's a hypthetical idea, what could be done about the issue. But as said, I don't know if it is possible to implement this with reasonable effort.

The current code does the following:

$|$

type \ -> $\|] (1) type n -> \[\n|] (2) type u -> \[\nu|] (3) type \ -> \[\nu\|] (4) type ] -> \[\nu$| (5)

In states (2) and (3) the slash is missing. For (2) it's not too problematic because the command is still invalid, so anyway you have to type on. Even though b) would be a better solution for this.

The only issue is that you cannot stop after (3), which is invalid LaTeX. If instead of (2) we could have b) then you could type u and stop. Since we don't have that at the moment you have to continue typing until (4). But then everything is fine again.

• Thiago
2012-11-07

Thanks for your quickly answer. Now I understand the point. In my case I can not stop at (4) since that when I type \ after \nu a lot of suggestions appear for auto-completion. So I have to move the cursor one point to right or continue typing ] to finally obtain $\nu$.

Thanks.

• Tim Hoffmann
2012-11-07

You are right about the auto-completion. In fact, that's another bug (just openend this https://sourceforge.net/p/texstudio/bugs/627/). So for the moment keep typing until (5).

• Priority: 1 --> 5*

• still present ?

• Tim Hoffmann
2013-05-27

The behavior described above is still present.

It would be desireable to have the alternative b) in state (2), i.e.

• when entering the closing bracket (at (1)), store the complete closing bracket (\] in this case)
• if it is clear, that the continued typing does not match the closing bracket (at (2)), restore the bracet. So instead of
type n -> $\n|] (2) I'd like to have type n -> \[\n|$ (2*)

Is this possible with reasonable effort?