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
Unexpected Behaviour On Snippets, When Moving Cursor Using <Tab> #363
Comments
@JustIdentity I did not reproduce your problem. I'm not sure if I understand wrong. |
I guess you were right, the real reason why I did submit this issue is because I want to make custom snippet like this. And working as expected. (I am still not sure why on this website doesn't work as expected on my computer) In the meantime, if you have spare time. Can you check where I did wrong? |
I preview your example, is the expected behavior. Is it a browser compatibility issue? @JustIdentity |
Found out the problem, the reason why it's resetting is because I use setter. So the whole element re-rendered. And probably that's the reason why the website didn't work (Code). |
import React from "react";
import CodeMirror from "@uiw/react-codemirror";
import { snippetCompletion } from "@codemirror/autocomplete";
import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
export default function App() {
return (
<div>
<CodeMirror
value="console.log('hello world!');"
height="200px"
extensions={[
markdown(),
markdownLanguage.data.of({
autocomplete: [
snippetCompletion("hello(${1}, ${2}) ${}", { label: "hello" })
]
})
]}
onChange={(value, viewUpdate) => {
console.log("value:", value);
}}
/>
</div>
);
} |
I think I will refactor CodeMirror Element, so it won't re-render every time the value change. Btw, thanks for the hardwork |
When we're using snippets autocompletion with multiple placeholder, and key are used to move between placeholder as expected on codemirror demo website
Link
While in @uiw/react-codemirror, unexpected behaviour happen. Instead move to next placeholder, key will add '\t' to start of the line.
Link
Extension used in codemirror website (src):
The text was updated successfully, but these errors were encountered: