securingsincity / react-ace

React Ace Component
http://securingsincity.github.io/react-ace/
MIT License
4.07k stars 605 forks source link

The cursor position does not match the input #659

Open xiaoguoqingxx opened 5 years ago

xiaoguoqingxx commented 5 years ago

Problem

There is a problem with the cursor position in my code

Sample code to reproduce your issue

<AceEditor 
                                width="100%" 
                                height="400px"
                                ref={editor}
                                mode="python"
                                fontSize="14px"
                                value={field.plugin_code}
                                showPrintMargin={false}
                                theme="chrome"
                                onChange={changeContent}
                                setOptions={{
                                    useSoftTabs: true
                                }}
                                cursorStart={1}
                                name="插件"
                                onFocus={focus("plugin_code")}
                                style={{ border:"1px solid var(--inputcolor)",lineHeight:"24px"}}
                                editorProps={{ $blockScrolling: Infinity }}

                            />

References

Progress on: # 微信截图_20190619180534

Athinodoros commented 5 years ago

I have the same experience the cursor has an offset of 4 slots

cretto commented 5 years ago

up

damianijr commented 5 years ago

same here, news?

patire-tu commented 5 years ago

Yes! We found this problem appeared in chrome version 72 and 74, but correct in verion above 76. It running normally in firefox browser, not precise. By the way, font-family replace with monospace is not effect at all!

mattwebdev commented 5 years ago

im getting this same error on chrome Version 77.0.3865.90 (Official Build) (64-bit)

any fix?

maheshsundaram commented 4 years ago

Hm, seeing the same issue in Firefox 74.0 (64-bit) and Chrome 78.0.3904.108 (Official Build) (64-bit) on macOS Mojave 10.14.6. Has anyone come up with a fix or workaround?

maheshsundaram commented 4 years ago

For me it turned out that a global rule was overriding the font-family for span which was causing the cursor issue:

// global.scss
span {
  font-family: $font-stack;
}

Solution for my use case:

// styles.module.scss
.ace_editor span, .ace_editor textarea {
  font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}
import styles from "./styles.module.scss";

export const Editor: React.FC = () => {
  return (
    <AceEditor className={styles.ace_editor} />
  )
}
flamz3d commented 2 years ago

for me this occurs 100% of the time, I think it is caused by the auto identing. Using with this csharp snippet:

namespace foo
{
[auto-indent] class MyClass
                      {
[auto-indent][auto-indent] public int bar: **<<<< cursor totally wrong**
                      }
}
xiaoguoqingxx commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。