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

auto completing identifiers starts with $ duplicates $ #2545

Open
4 tasks done
sapphi-red opened this issue Dec 10, 2020 · 5 comments
Open
4 tasks done

auto completing identifiers starts with $ duplicates $ #2545

sapphi-red opened this issue Dec 10, 2020 · 5 comments

Comments

@sapphi-red
Copy link
Contributor

sapphi-red commented Dec 10, 2020

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ
  • I have tried restarting VS Code or running Vetur: Restart VLS

Info

  • Platform: Win
  • Vetur version: 0.31.1
  • VS Code version: 1.15.1

Problem

<script lang="ts">
import Vue from "vue"

declare const $vvvvv: any
declare const vvvvv: { $ppp: any }
type $ttttt = any

// here auto completing will change this to `$$vvvvv`
$vv

// here auto completing will change this to `vvvvv.$$ppp`
// but when you type through `vvvvv.$` and trigger auto complete, it will change to `vvvvv.$ppp`
vvvvv.$

// here it will change to `$$ttttt`
const aa: $tt

export default Vue.extend({
  data() {
    return { $vvvvv }
  }
})
</script>

<template>
  <div>{{ $vv }}</div> <!-- same with here -->
</template>

It works correctly inside a normal .ts file.

Reproducible Case

Just copy the script above to https://github.com/octref/veturpack.

@sapphi-red
Copy link
Contributor Author

Changing the line below to (entry.replacementSpan && convertRange(scriptDoc, entry.replacementSpan)) ?? (completions.optionalReplacementSpan && convertRange(scriptDoc, completions.optionalReplacementSpan)) fixed this.
But it will change the behavior when it's like $tt|aa (| is the cursor). (it changes the result from $tttttaa to $ttttt)

const range = entry.replacementSpan && convertRange(scriptDoc, entry.replacementSpan);

Also using service.getNameOrDottedNameSpan partially fixed it. It broke property auto complete. (I think my implementation was not good.)

Maybe relating
https://github.com/microsoft/vscode/blob/86a23116059de7fab0b0ac0722307f70135f03ed/src/vs/editor/contrib/suggest/suggest.ts#L203-L205
microsoft/monaco-editor#397

@yoyo930021
Copy link
Member

You can refer this file in VSCode.
This is where VSCode implements typescript completion.

@jasonlyu123
Copy link
Contributor

I think this is because the $ character is not treated as part of an identifier by vscode.
圖片
圖片
The $ is not highlighted like i of the first picture

@jasonlyu123
Copy link
Contributor

Another way I found is to add a wordPattern language configuration. This would let vscode determine what is a word. I tried it on my fork jasonlyu123@38de5b1. It's related to the maybe related link you provide.

@yoyo930021
Copy link
Member

Most likely @jasonlyu123 says.
But I can't determine if this solution is possible.

Because we have many language in one file. =_=

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

No branches or pull requests

3 participants