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

Characters inserted in wrong section when using Snippets #843

Closed
frederickfogerty opened this issue Oct 5, 2016 · 6 comments
Closed

Characters inserted in wrong section when using Snippets #843

frederickfogerty opened this issue Oct 5, 2016 · 6 comments
Labels

Comments

@frederickfogerty
Copy link
Contributor

frederickfogerty commented Oct 5, 2016

  • Click thumbs-up 👍 on this issue if you want it!
  • Click confused 😕 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


What did you do?

Set-up: empty file, insert mode, trigger with multiple sections - example below

  1. Type a snippet trigger (in my case: rnc), and press tab.
  2. Type some characters for the first section of the snippet.
  3. Press Enter OR Tab to select the next snippet section.
  4. Type anything - the first character of what you typed will be appended to all the instances of the previous section.

GIF of problem:
oct-06-2016 09-59-17

What did you expect to happen?

The characters I typed the second section would only occur in the second section.

What happened instead?

The first character I typed in the second section is added to the first section, and is not typed in the second section

Technical details:

  • VSCode Version: 1.5.3
  • VsCodeVim Version: 0.3.0
  • OS: OSX 10.11.5

Other details

*Snippet used: *

    "reactNativeComponent": {
        "prefix": "rnc",
        "body": [
            "import * as React from 'react';",
            "import { StyleSheet, Text, View } from 'react-native';",
            "",
            "interface I${1:componentName}Props {}",
            "",
            "class ${1:componentName} extends React.Component<I${1:componentName}Props, void> {",
            "\tpublic render() {",
            "\t\treturn (",
            "\t\t\t<View style={styles.container}>",
            "\t\t\t\t<Text>$0</Text>",
            "\t\t\t</View>",
            "\t\t);",
            "\t}",
            "}",
            "",
            "const styles = StyleSheet.create({",
            "\tcontainer: {} as React.ViewStyle,",
            "});",
            "",
            "export default ${1:componentName};"
        ],
        "description": "Creates a React Native component with styles and props"
    },
@xconverge
Copy link
Member

This should be fixed on master from #837

@frederickfogerty
Copy link
Contributor Author

Thanks @xconverge, I'll wait for master to be pushed as a release and can verify this is fixed then.

@rebornix
Copy link
Member

This bug is actually much severe than expected and it's still not fixed. The reason that the first T gets injected into previous position is that while in Multi Cursor Mode, we don't ever update our internal cursor position in time. So once you use tab to switch the cursor, our extension's internal cursor position is out of date. Then you type T, as it's still Insert Mode, our InsertMode handler kicks in, and inserts text at old cursor position.

Another problem is, when you use tab to switch the cursor, Code will help select all the text you previously typed in that section of the snippet. And you can always keep pressing tab to switch between all sections. Currently our internal selectionChangeHandler has a hard time with it.

I've tried multiple ways to get rid of this issue this afternoon and finally came up with one solution that looks reasonable to me, which is delegating everything back to Code if it's in Insert Mode and Multi Cursor. Will send out that PR later.

@xconverge
Copy link
Member

hmm I partially fixed this...but it looks like I may have broke that when you start the snippet, everything is selected, let me see

@Chillee
Copy link
Member

Chillee commented Jun 20, 2017

Is this still an issue? I can't seem to replicate it.

@J-Fields
Copy link
Member

I don't think this specifically is still an issue. Snippets are still rather wonky (#3005, for example), but will be fixed by #4570.

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

No branches or pull requests

6 participants