Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with "smart enter" #41

Closed
mqualizz opened this issue Aug 29, 2017 · 3 comments
Closed

Problems with "smart enter" #41

mqualizz opened this issue Aug 29, 2017 · 3 comments

Comments

@mqualizz
Copy link
Contributor

mqualizz commented Aug 29, 2017

I love your plugin -- it gets better with every release.

I have found a few issues with the "smart enter" completion behaviour.

As far as I can tell, if you hit <enter> two things happen w.r.t completion behaviour/"smart enter":

  1. If the cursor is in a block with a missing end then an end is inserted on the next line (same withuntil, etc)
  2. Some code is reformatted

First, please, please, please remove (2), or add an option to turn off automatic code formatting. Not only do I hate it when my code is reformatted by the IDE, but the current logic has some bugs which makes the reformatting 'broken' in certain situations.

Bugs:

  1. In the simple case, the cursor is not properly positioned.
    E.g. (for this, and all further examples, | represents the position of the cursor)
    If you have
if someCondition then|

and hit <enter>, you get

if someCondition then|
end

instead of

if someCondition then
    |
end
  1. If there is no space between the current keyword and the missing end (etc) from an outer block, the end is not recognized. And things get weird.

e.g. Just say this is your original code

if a then doSomething() end
nextLine
anotherLine
thirdline

then you replace doSomething() with another (incomplete) condition, (notice, no space between then and end)

if a then if b then|end
nextLine
anotherLine
thirdline

and hit <enter> (notice how then end keyword is inserted, but incorrectly, how the end following the cursor is not recognized, and how everything gets indented when it shouldn't be)

if a then if b then|
    endend
    nextLine
    anotherLine
    thirdline

and hit <enter> a second time (this is just the first bug showing up again)

if a then if b then
end
    endend
    nextLine
    anotherLine
    thirdline

The behaviour seems to depend on what follows the cursor. For example:
Initial code:

if a then return end
nextLine
anotherLine
thirdline

Add a new, incomplete condition (again, no space between then and return)

if a then if b then|return end
nextLine
anotherLine
thirdline

hit <enter>

if a then if b then|
    endreturn end
nextLine
anotherLine
thirdline

hit <enter> again

if a then if b then|
end
    endreturn end
nextLine
anotherLine
thirdline
@DoctorGester
Copy link

Oh so that's when reformat happens... I couldn't quite catch it, very annoying indeed

@tangzx
Copy link
Member

tangzx commented Aug 30, 2017

Thanks a good issue.
2017-08-30_09-34-12

2017-08-30_09-35-52

Also added a settings for smart enter, you can on/off it 😃
image

Anything else?

@tangzx tangzx closed this as completed in 60da9be Aug 30, 2017
@mqualizz
Copy link
Contributor Author

You're awesome, thank you :-)

Does that "smart close 'end'" feature also cover "until"? For example, repeat if a then|until condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants