autocomplete-plus icon indicating copy to clipboard operation
autocomplete-plus copied to clipboard

issues in `replacementPrefix` when the replaced `prefix` is a paragraph and wrapped in several lines.

Open johnking opened this issue 8 years ago • 1 comments

Hi there,

I found this issue when I try to convert unicode text (such as Chinese) into a JSON format, but I can reproduce it easily with any text such as English.

How to reproduce

  1. I implemented a simple suggestion list with 3 options: "Introduction", "text" and "summary" to replace a certain paragraph based on users' choice, so the prefix will be the whole paragraph instead of a single word.

screen shot 2017-09-13 at 22 39 16

screen shot 2017-09-13 at 22 39 31

  1. If the paragraph is one line long, it works
  2. If the paragraph is two line long, then the replacement will be inserted after the first character
  3. If the paragraph is three line long, then the replacement will be inserted after the first two characters and so on.

screen shot 2017-09-13 at 22 40 02

Noted two issues:

  • the replacement was inserted in wrong place, and
  • the Put should not be there.

Best

-John

johnking avatar Sep 14 '17 02:09 johnking

The default prefix (which I'm assuming the default provider uses) only captures a single line at most.

If you are writing your own package with your own prefix, I suggest also writing your own replacement prefix / just using the one you've already written. Additionally, the provider API allows for an optional method called immediately after a text insertion. That may be of use.

Also, you should note that your "how to reproduce" section is severely lacking. Having read it, I still have no idea how to replicate it myself. That final image looks like it was inserted after 4 characters, not 3.

Aerijo avatar Nov 28 '17 09:11 Aerijo