提交 77454b24 编写于 作者: M Matt Bierner

Extract append joined placeholders

上级 0aef227b
......@@ -635,13 +635,7 @@ export function snippetForFunctionCall(
const snippet = new vscode.SnippetString(`${item.insertText || item.label}(`);
const parameterListParts = getParameterListParts(displayParts, item.label);
for (let i = 0; i < parameterListParts.parts.length; ++i) {
const paramterPart = parameterListParts.parts[i];
snippet.appendPlaceholder(paramterPart.text);
if (i !== parameterListParts.parts.length - 1) {
snippet.appendText(', ');
}
}
appendJoinedPlaceholders(snippet, parameterListParts.parts, ', ');
if (parameterListParts.hasOptionalParameters) {
snippet.appendTabstop();
......@@ -651,6 +645,20 @@ export function snippetForFunctionCall(
return snippet;
}
function appendJoinedPlaceholders(
snippet: vscode.SnippetString,
parts: ReadonlyArray<ParamterPart>,
joiner: string
) {
for (let i = 0; i < parts.length; ++i) {
const paramterPart = parts[i];
snippet.appendPlaceholder(paramterPart.text);
if (i !== parts.length - 1) {
snippet.appendText(joiner);
}
}
}
interface ParamterPart {
readonly text: string;
readonly optional?: boolean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册