Bracket completion/auto formatter issue

11 posts, 0 answers
  1. Andrei
    Andrei avatar
    30 posts
    Member since:
    May 2012

    Posted 19 Jul 2012 Link to this post

    Hi guys,

    As shown there http://blogs.telerik.com/blogs/posts/10-04-16/justcode-q1-sp1-ndash-typing-assistance-improvements.aspx bracket completion works even when there is already a statement allowing you to easily surround the statement with curly braces.

    This is really cool and it works, however autoformatting doesn't seem to play nice. Perhaps I'm missing out on some settings but I haven't changed much from the defaults. Let me explain:

    You start with this:
    if (blah-blah)
         DoThat();

    Then you type an opening bracket and JC automatically adds a closing one and moves the cursor at the end of the statement:
    if (blah-blah)
    {    DoThat();|}

    So far so good and it's even better than what's shown in the old blog post as the cursor was not moved there so as you hit Enter the cursor remained at the begining of the statement. Now it's at the end and when I hit Enter I get this:
    if (blah-blah)
    {    DoThat();
    |}

    Kind of asking for a fix, ain't it? ;)

    The expected behavior is:
    if (blah-blah)
    {
        DoThat();|
    }

    with the cursor at the end so you can hit Enter once again and contunue typing some new statements inside the block.
  2. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 19 Jul 2012 Link to this post

    Hello Andrei,

     Thanks for the detailed information.
    Indeed, what you described is the best expected behaviour. Actually it was working like that before, but we had to change it because some issues appeared at some moment.
    We will discuss it  again within the team, but unfortunately it will remain this way for now.
    Thanks.

    Please, do not hesitate to contact us if you have any further questions or need of assistance.

    All the best,
    Zdravko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Andrei
    Andrei avatar
    30 posts
    Member since:
    May 2012

    Posted 19 Jul 2012 Link to this post

    Hi Zdravko,

    Could you please let us know on the outcome of the discussion? We're all devs here and we can understand technical implications.

    Hope to hear from you soon!
  5. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 23 Jul 2012 Link to this post

    Hello Andrei,

    We changed it, because we had some problems with the formatter.
    After we discussed it again, we think to improve it in the way you expect and it should be.
    We are thinking to do it like the example below. 

    1.Start with this:
    if (true)
                DoThat();

    2.After putting opening bracket it become:

    if (true)
                {DoThat();|}

    3.And then the user could choose between two possibilities:

    3.1 If your cursor is staying at the position like in step 2 above and press Enter the code become:

    if (true)             {                 DoThat(); |             }
    3.2 Otherwise you could move the cursor before the method (after the opening bracket) and press Enter:
    if (true)             { | DoThat();             } 

    What do you think?
    If you have any ideas feel free to share. 
    Thanks and have a nice day.

    Kind regards,
    Zdravko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Andrei
    Andrei avatar
    30 posts
    Member since:
    May 2012

    Posted 23 Jul 2012 Link to this post

    Hi Zdravko,

    I think it would be better for case 3.2 to expect a user to enter something like Ctrl+Enter or Shift+Enter. Suppose I would like to surround a statement with block braces. I know such a command is available in JC but it would be natural to expect when going from 2 to 3.2 that if your cursor is at the begnining hitting Enter will just place the statement on a new line. Just like any regular editor would do.
    But with some 'special Enter' a user can opt in to a special behavior as you show in 3.2.

    As to 3.1 I'm all for it! Well, you can actually consider a 'special Enter' here as well and don't extra line feed. That would be even more consistent... (just noticed I didn't add an extra line in the expected behavior in my original post either, I guess it makes sense, I may not necessarily want to type a new statement, instead I can just stop there, effectively completing the 'surround with block command').

    I'm really glad you guys are on it!
  7. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 26 Jul 2012 Link to this post

    Hello Andrei,

     We made it in the following way.
    if you are here:

    if (true)
    {DoThat();|} 

    And you press Shift + Enter it become:

    if (true) 
    {
      |
    DoThat();
    }  

    Otherwise (just Enter) :

    if (true) 
    {
      DoThat();
    |
    }   

    In case you do not want to write in the block just hit Right Arrow + Enter.

    If you cursor position is behind the opening bracket:

    if (true)
    {|DoThat();}  

    The key combination does the opposite:
    • Shift + Enter - the cursor is behind the statement
    • Enter - the cursor is before the statement

    Regards,
    Zdravko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Andrei
    Andrei avatar
    30 posts
    Member since:
    May 2012

    Posted 26 Jul 2012 Link to this post

    Hi Zdravko,

    So the Shift+Enter combination actually means 'put the cursor at the opposite side and do Enter' which is pretty easy to grasp.
    I believe RightArrow+Enter works as well when the cursor is after an opeining bracket, right?

    All in all the behavior is pretty good! Thanks!

    I'm wondering if it's possible to evolve on this 'opposite Enter' feature and make it work this way in all scenarios, like:
    {
         Console.WriteLine();|
    }

    Shift+Enter and you have:
    {
        |
        Console.WriteLine();
    }


    And in reverse:
    {
        |Console.WriteLine();|
    }

    Shift+Enter and you have:
    {
        Console.WriteLine();
        |
    }


    That'd be pretty cool, what do you think? Or maybe it already does this? ;)
  9. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 31 Jul 2012 Link to this post

    Hello Andrei,

     It is working only in scenarios when the brackets are at the same line with the statement so far.
    Maybe we will evolve it further in the future but for now we have some more prioritized items.
    Thanks.

    Regards,
    Zdravko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. Andrei
    Andrei avatar
    30 posts
    Member since:
    May 2012

    Posted 16 Aug 2012 Link to this post

    Hi Zdravko,

    I've checked the feature on the latest version (815) and it works great! I didn't even expect how well it would improve typing assistance.

    There is one little issue however - this feature adds tabs instead of spaces and when I save the file I get notified by 'untabify' feature of Productivity Power Tools that there are mixed tabs/spaces in my file. I prefer to keep my files clean and prefer spaces over tabs.

    Could you please look into it?

    Btw, I added a PIT item about adding a similar 'untabify' feature to JC but it's not visible in the list. Is this ok? Do PIT items undergo some kind of initial check and approval?
  11. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 21 Aug 2012 Link to this post

    Hello Andrei,

     Thanks for the reply.
    Indeed, this is happening because we do not use the VS setting, but we have an item for that in our ToDo list and we will improve it in the near future.
    FYI: I am not sure whether you are aware that there are some conflicts between JC and this productivity tool when used together, especially when Typing assistance is enabled.
    Regarding to the PITS items, they have to be approved before published.
    Thanks and stay tuned.

    Regards,
    Zdravko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  12. Andrei
    Andrei avatar
    30 posts
    Member since:
    May 2012

    Posted 21 Aug 2012 Link to this post

    Hi Zdravko,

    Yes I know about possible conflicts and have brace completion of Power Tools off (which is a shame because it's one of the best implementations I've seen with its Tab-through-braces and Shift+Enter statement completion features). I enabled JC's typing assitance bacause I find 'smart semicolon' very useful. And _this_ in turn is a shame ;) bacause it often lags behind and doesn't work as it depends on code analysis to complete...

    Hope you guys are going to improve in these areas!
Back to Top
DevCraft banner