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

[Bug] Tab only accept the empty space #4452

Open
1 of 2 tasks
BeishaoCao-db opened this issue Mar 29, 2024 · 3 comments
Open
1 of 2 tasks

[Bug] Tab only accept the empty space #4452

BeishaoCao-db opened this issue Mar 29, 2024 · 3 comments

Comments

@BeishaoCao-db
Copy link

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.47.0#XQAAAAJQAgAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw1r3sCnGBGpWlpVktocO7_BJCkQTDFxvol36GvVmJLcE84C3knSa45xr2hL4V3CzK7RsXTTl3GKNcoe1EOluseUOqlAiRzt565Aikzvea61xWU_C6O4O4af9d95Ho8N37E04AP_F4QgtoH62aRToKkEAPJZoSsZZfAcW23V_8iVY6IVDJixX7Qj5iTFcYx3oLLpyOrtWl5zCHbN-ayZrwUeHldP8jznwshtDv_rgKRk-aCws0DDW2EPOv5b5f_xemFBnpV9OH_7CG5c1Z7OsTHfGIu7oi9k30gjuf2n26CCHN7kRQ-Sye4CP3wTY_3KIXJzrmOTR4TMCrfTPmM8Oi2diYm4dP9RHHrmilKrj-bUnY

Monaco Editor Playground Code

monaco.languages.registerInlineCompletionsProvider("sql", {
	provideInlineCompletions: function (model, position, context, token) {
		console.log('Provide new completion', position, context, token)
		return {items: [
                    {
                        insertText: '  buhao'
                    },
                ]};
	},
	freeInlineCompletions: function (completions) {
		console.log(completions);
	},
}); 

monaco.editor.create(document.getElementById("container"), {
	value: 'SELECT\n  *',
	language: "sql",
});

Reproduction Steps

  1. Open the playground
  2. Type an enter
  3. You will see ' buhao' suggested
  4. Tab
  5. You will see empty space accepted

Actual (Problematic) Behavior

Tab can only accept empty space

Expected Behavior

Tab accept the full suggestion

Additional Context

Screen.Recording.2024-03-29.at.2.43.04.PM.mov

Try on 0.43,0.44,0.47, all don't work. Have to mention, sometimes it works, sometimes it doesn't. Not sure what's the pattern

@qirong77
Copy link

qirong77 commented Apr 1, 2024

This Is seems to InlineCompletion's inside strategy rather than a bug,When the current line is empty and your insertText is start with more than a tab size blank string(eg: text), The cursor will close to your completion first rather then accept it, you should change your insertText at first tab to handle this situation.
Apr-01-2024 16-04-23

@BeishaoCao-db
Copy link
Author

BeishaoCao-db commented Apr 4, 2024

@qirong77 Yes, that's my first assumption. However, in the example I provided, if you change the initial code to be select\n rather than select\n *, then you will see tab can accept something with tab size blank string.

e.g. Is it because monaco detect size to be 4 then?

If that's the case, let me change the logic then

@qirong77
Copy link

qirong77 commented Apr 4, 2024

@BeishaoCao-db Wow, You are right. May be because the initial code changes the editor's tab size in some case. When you set your insertText to a larger blank string like buhao,you will find it don't work again.
e.g.

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

No branches or pull requests

2 participants