foldStart & foldEnd can depend on editor.action.commentLine to some extent. Since you will most likely install plugins when using the target language, you don't need to worry about the comment format. Taking a step back is still possible to customize using the config file
Is there anything special about foldStartRegex & foldEndRegex? Just match if #region or #endregion exists in a single line, so all languages are common.
i tried
async edit => {
if (!currentLanguageConfig) { return; }
if (!ate) { return; }
//Now, move the selection point to the [NAME] position.
var sel = ate.selection;
var region_cur_Line = sel.start.line - 1;
var region_newStartPosition = sel.start.translate(region_cur_Line - sel.start.line, 0);
var selection_region = new vscode.Selection(region_newStartPosition, region_newStartPosition);
var selection_endregion = new vscode.Selection(sel.end, sel.end);
ate.selections = [selection_region, selection_endregion];
// 利用 vscode 添加注释
// await 是为了确保应用了注释
await vscode.commands.executeCommand(
"editor.action.commentLine",
"editorHasDocumentFormattingProvider && editorTextFocus",
true
);
// 格式化后才可以获得准确的位置
// 也不知道格式化会不会修正选中的位置
//Format the document
await vscode.commands.executeCommand(
"editor.action.formatDocument",
"editorHasDocumentFormattingProvider && editorTextFocus",
true
);
// Now, move the selection point to the [NAME] position.
region_newStartPosition = region_newStartPosition.with(region_cur_Line, ate.document.lineAt(region_cur_Line).text.indexOf("#region") + 8);
var newSelection = new vscode.Selection(region_newStartPosition, region_newStartPosition);
ate.selections = [newSelection];
}
foldStart & foldEnd
can depend oneditor.action.commentLine
to some extent. Since you will most likely install plugins when using the target language, you don't need to worry about the comment format. Taking a step back is still possible to customize using the config fileIs there anything special about foldStartRegex & foldEndRegex? Just match if
#region
or#endregion
exists in a single line, so all languages are common.i tried
xmake uses lua syntax, but my regex doesn't need to match '--' at all