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

重写 provideCompletionItems 方法时 insertTextRules 设置了默认值 #132

Closed
liuxy0551 opened this issue Jun 18, 2024 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@liuxy0551
Copy link
Collaborator

liuxy0551 commented Jun 18, 2024

const  completionItems: languages.CompletionItem[] = unwrappedCompletions.map(
	(item) => ({
		...item,
		insertText:
			item.insertText ??
			(typeof item.label === 'string' ? item.label : item.label.label),
		range: item.range ?? wordRange,
		insertTextRules:
			item.insertTextRules ??
			languages.CompletionItemInsertTextRule.InsertAsSnippet
	})
);

  monaco-editor 中没有设置 insertTextRules 的默认值,加上的话会需要在使用的地方明确传入 insertTextRules 的值,否则可能产生不明就里的问题,比如禅道 #81899。

  补全表名时,表名含有 $ 特殊字符,此时就需要明确 insertTextRules 的值为 KeepWhitespace;对于函数名含有 $ 特殊字符时,需要对函数名中的 $ 字符进行转义 (\\$) 处理,insertTextRules 的值依旧为 InsertAsSnippet

2024-06-18 11 34 21

@HaydenOrz
Copy link
Collaborator

建议把默认值去掉
这里写成这个默认值,导致Monaco SQL Languages 的补全项的默认行为与 Monaco 原生 API的行为不同,

liuxy0551 added a commit to liuxy0551/monaco-sql-languages that referenced this issue Jun 18, 2024
@HaydenOrz HaydenOrz added the bug Something isn't working label Jun 18, 2024
@HaydenOrz HaydenOrz assigned HaydenOrz and liuxy0551 and unassigned HaydenOrz Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants