microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.78k stars 29.11k forks source link

Suggestions triggered when the editor in in composition phase #83428

Closed La-Paranoia closed 2 years ago

La-Paranoia commented 5 years ago

Issue Type: Bug

Microsoft wubi Chinese input situation, in the HTML page input div, Chinese options and code prompt at the same time!This is probably due to the built-in extension Emmet!Please update and improve!

VS Code version: Code 1.39.2 (6ab598523be7a800d7f3eb4d92d7ab9a66069390, 2019-10-15T15:35:18.241Z) OS version: Windows_NT x64 10.0.18362

Extensions (18) Extension|Author (truncated)|Version ---|---|--- markdown-toc|Ala|1.5.6 htmltagwrap|bra|0.0.7 vscode-eslint|dba|1.9.1 auto-rename-tag|for|0.1.0 beautify|Hoo|1.5.0 vscode-fileheader|mik|0.0.2 vscode-filesize|mkx|2.1.3 vscode-autoprefixer|mrm|2.2.0 vscode-language-pack-zh-hans|MS-|1.39.3 vetur|oct|0.22.4 vscode-css-peek|pra|3.0.2 format-html-in-php|rif|1.6.1 code-spell-checker|str|1.7.18 highlight-matching-tag|vin|0.9.5 vscode-icons|vsc|9.4.0 vscode-todo-highlight|way|1.0.4 vscode-import-cost|wix|2.12.0 html-css-class-completion|Zig|1.19.0 (8 theme extensions excluded)
vscodebot[bot] commented 5 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

rebornix commented 5 years ago

Turns out to be a bug when users are using an IME which inserts keystrokes into the editor first and then replaces them with user selected characters. Emmet listens to content change and our suggestion API doesn't talk about the state of IME (which is correct).

jakebailey commented 4 years ago

Something that was reported for python: microsoft/python-language-server#1751

Depending on the input, completion may or may not show up after the string gets replaced.

BOT-Man-JL commented 4 years ago

The auto complete doesn't work for non-ascii code snippet prefix in markdown editor... (Similar to https://github.com/microsoft/python-language-server/issues/1751)

issue1

The suggestion of non-ascii snippet prefix can show up only when hit the keyboard shortcut:

issue2

My snippet for markdown editor:

    "t": {
        "prefix": "t",
        "body": "test",
        "description": "Ascii is OK."
    },
    "`": {
        "prefix": "·",
        "body": "`",
        "description": "Fix Chinese IME."
    }

My editor setting for markdown editor:

    "[markdown]": {
        "editor.quickSuggestions": {
            "other": true,
            "comments": true,
            "strings": true
        },
        "editor.tabCompletion": "on",
        "editor.snippetSuggestions": "top"
    }
alexdima commented 2 years ago

I believe this issue contains today 3 different problems (although they might appear similar).


Regarding the 1st issue of Emmet + HTML

@La-Paranoia @rebornix I can't reproduce any problems in HTML. Your comments didn't have clear steps, so here is what I am trying and works for me:

https://user-images.githubusercontent.com/5047891/139413010-a41564ca-72f2-4b47-9df5-623463c55a6b.mp4


Regarding the 2nd issue of suggestions not popping up

@nobodxbodon I followed the steps from https://github.com/microsoft/python-language-server/issues/1751 :

function f() {
    const 需 = 5;
    for (const 名字 of [1,2,3,4,5,6,7,8,9,10]) {
        console.log(名字);
        console.log()
    }
}

https://user-images.githubusercontent.com/5047891/139414585-40a5077d-5f84-4652-b574-765e8eb3c6c9.mp4


Regarding the 3rd issue of non-word characters

@BOT-Man-JL This does not appear to be an issue with IME at all. It looks like you desire to have the suggest widget to pop up automatically after writing a word separator character. AFAIK the suggest widget does not support this. Please create a separate feature request with your use case (snippets that are bound to word separators).

nobodxbodon commented 2 years ago

@alexdima thanks for follow-up. 2nd issue happened for Python, but not for TS. I just reproduced it in Python, input 名 but 名字 didn't pop up:

https://user-images.githubusercontent.com/392497/139517794-384ef31e-3723-436c-9b02-2882e19b3362.mov

alexdima commented 2 years ago

Thank you for the extra information. I could form a clear understanding of what was going on:

It turns out that this got fixed via https://github.com/microsoft/vscode/commit/de2f16bde7b25bde35b88c63e18ee05cc1a6d827 for #123672, but it only got released to stable 1.62.0 on Nov 4th

nobodxbodon commented 2 years ago

Hi @alexdima thanks for informing. I just tested in 1.62.3 (version info below) but still had the same issue as before. Like before, it doesn't work for 名 in 名字, but does work for 需 in 需求.

Version: 1.62.3 (Universal) Commit: ccbaa2d27e38e5afa3e5c21c1c7bef4657064247 Date: 2021-11-17T07:59:13.865Z Electron: 13.5.2 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin arm64 21.1.0

alexdima commented 2 years ago

Here are the steps I am trying:

without the Python extension:

https://user-images.githubusercontent.com/5047891/144322749-68a4fa21-1266-4af9-a1eb-18b464c5364b.mp4

with the Python extension:

https://user-images.githubusercontent.com/5047891/144323158-9f517929-c29f-4dcb-b9b1-986c8539485e.mp4

@jrieken It looks to me that the Python extension is returning 名字 as a suggestion, just like word suggestions do, but when composition ends the suggestion is not shown. I would have thought that https://github.com/microsoft/vscode/commit/de2f16bde7b25bde35b88c63e18ee05cc1a6d827 would cover this case/

NOTE: when trying the same with 需求 instead of 名字 and typing xu and 1, it works correctly which is very confusing for me. Maybe there are some hidden properties used in these suggestions and those don't agree? 🤷

https://user-images.githubusercontent.com/5047891/144323553-e4b98fe3-9fc7-4ffe-b3c7-6019143ac211.mp4

nobodxbodon commented 2 years ago

Indeed it's puzzling that some characters work but others don't. Here are some more that don't work: 不 (pinyin is bu)、好(hao)。 Another thing I notice, if auto-complete is triggered before typing, then the suggestion will show after typing:

https://user-images.githubusercontent.com/392497/144353113-786c5367-4e7c-4350-84d6-bc4c50a4d27b.mov

jrieken commented 2 years ago

Need to debug but it might be that kick off "as you type" suggestions but that we don't recognize this as a word-end correctly

jrieken commented 2 years ago

This is what happens:. When starting composition IntelliSense is triggered (the same bug as https://github.com/microsoft/vscode/issues/132939), this retrieves and filters completions. Now, ending composition triggers suggest again but since it is already active nothing happens. Also, we don't let 名字 reappear because our assumption is that more typing hides more completions (and not making some reappear again). This issue will also be fixed by the change for https://github.com/microsoft/vscode/issues/132939

nobodxbodon commented 2 years ago

I just tested in version below, and 名字 好 不 all work now. Thanks!

Version: 1.63.0 (Universal) Commit: 7db1a2b88f7557e0a43fec75b6ba7e50b3e9f77e Date: 2021-12-07T05:15:48.091Z (3 days ago)