feat: add quick toggle comment functionality in the editor (#13107)

This commit is contained in:
2026-06-24 18:23:51 +08:00
committed by GitHub
parent 86aa6c09c6
commit 3e0d0bb809
3 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ const isSpecialEditorFileName = (value: string) => {
if (!normalized) {
return false;
}
return specialEditorFileNames.some((filename) => normalized === filename || normalized.startsWith(`${filename}.`));
return specialEditorFileNames.some((filename) => normalized === filename);
};
export const resolveEditorLanguage = (path: string, extension = '', name = '') => {
+1
View File
@@ -41,6 +41,7 @@ export async function loadMonacoLanguageSupport() {
import('monaco-editor/esm/vs/editor/contrib/folding/browser/folding.js'),
import('monaco-editor/esm/vs/editor/contrib/contextmenu/browser/contextmenu.js'),
import('monaco-editor/esm/vs/editor/contrib/clipboard/browser/clipboard.js'),
import('monaco-editor/esm/vs/editor/contrib/comment/browser/comment.js'),
import('monaco-editor/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js'),
import('monaco-editor/esm/vs/editor/contrib/find/browser/findController.js'),
import('monaco-editor/esm/vs/editor/contrib/multicursor/browser/multicursor.js'),
@@ -965,6 +965,8 @@ const initEditor = async () => {
editor.getModel()?.pushEOL(config.eol);
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, quickSave);
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Slash, quickToggleComment);
editor.focus();
editor.onDidChangeModelContent(() => {
if (editor) {
@@ -980,6 +982,10 @@ const quickSave = () => {
saveContent();
};
const quickToggleComment = () => {
void editor?.getAction('editor.action.commentLine')?.run();
};
const openHistoryDrawer = () => {
if (!form.value.path) {
MsgWarning(i18n.global.t('file.historyNeedFile'));