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

Incorrect text insertions #5

Open
1 of 3 tasks
g-plane opened this issue Apr 10, 2024 · 2 comments
Open
1 of 3 tasks

Incorrect text insertions #5

g-plane opened this issue Apr 10, 2024 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@g-plane
Copy link

g-plane commented Apr 10, 2024

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

Describe the bug

For the text below:

console.log("Hello, World!")

If we select the not completion item, it will become:

console.log("Hello, !World!")

Besides, if we select the par completion item, it will become:

console.log("Hello, (World!"))

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@NWYLZW
Copy link
Owner

NWYLZW commented Apr 10, 2024

The current logic for evaluating expressions does not strictly follow semantic expressions, so it cannot accurately determine certain special cases like strings.

let expressionStart = position.offset - 1
// find the start of the line view width start
while (expressionStart > 0 && ![
' ',
'\t',
'\r',
'\n'
].includes(value[expressionStart - 1])) expressionStart--

Due to the nature of expressions, they tend to be more language-agnostic. Although it may be more appropriate to have corresponding language-specific start and end markers for expressions, it would significantly increase the maintenance and development costs for me. I plan to address this issue by following these steps:

  • single and dubdle quote: '', ""
  • backtick: `
  • brackets: [], (), <>, {}
  • single comment: //
  • multiple comment: /**/

If anyone can provide assistance with this feature, I would greatly appreciate it.

@NWYLZW NWYLZW self-assigned this Apr 10, 2024
@NWYLZW NWYLZW added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Apr 10, 2024
@NWYLZW NWYLZW pinned this issue Apr 10, 2024
@g-plane
Copy link
Author

g-plane commented Apr 10, 2024

You can consider tree-sitter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants