vscode-nim icon indicating copy to clipboard operation
vscode-nim copied to clipboard

A not working feature, which would result in a bug...

Open RSDuck opened this issue 8 years ago • 2 comments

I found this passage of the code very interesting:

decreaseIndentPattern: /^\s*(((return|break|continue|raise)\n)|((elif|else|except|finally)\b.*:))\s*$/

I assume the (return|break|continue|raise)\n should decrease the identation in the next line, when the user types return, break, continue or raise. But this doesn't work.

I got it to work by adding the following to the onEnterRules:

{
                beforeText: /^\s*((return|break|continue|raise))\s*$/,
                action: { indentAction: vscode.IndentAction.Outdent }
},

But this results in the following bug:

proc f() =
  if true:
    |

(| is where the cursor is) When return is typed, the next line gets outdented once after typing enter. Then when else: is typed, the else outdents once again. Now the else is too far outdented.

And that's why I'm asking if this is intended, or not?

RSDuck avatar Feb 28 '17 17:02 RSDuck

It is because onEnterRules conflicts with decreaseIndentPattern in this case. I guess onEnterRules breaks inner indent counters state of VSCode, It is possible use this workaround:

   beforeText: /^\s*((return|break|continue|raise))\s*$/,
   action: { indentAction: vscode.IndentAction.None, removeText: 2 }

but it will work only for fixed tab size

kosz78 avatar Mar 01 '17 02:03 kosz78

Yes it does works. Hm I'm wondering if there's a real fix to this problem(beside just leaving it as is it/removing the ((return|break|continue|raise)\n) from the regex)...

RSDuck avatar Mar 01 '17 18:03 RSDuck