Skip to content

Commit 58a5252

Browse files
committed
✨ feat: 优化点击 Run Snippet Script 菜单后列表取数逻辑,通过 showInRunSnippetScript 字段开启
1 parent ad4cca0 commit 58a5252

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/commands/runSnippetScript.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ export const registerRunSnippetScript = (context: vscode.ExtensionContext) => {
1616
'lowcode.runSnippetScript',
1717
async () => {
1818
const templateList = getSnippets().filter(
19-
(s) => !s.preview.notShowInCommand,
19+
(s) => s.preview.showInRunSnippetScript,
2020
);
2121
if (templateList.length === 0) {
22-
window.showErrorMessage('请配置模板(代码片段)');
22+
window.showErrorMessage(
23+
'请配置模板(通过 showInRunSnippetScript 字段开启)',
24+
);
2325
}
2426
const templateResult = await window.showQuickPick(
2527
templateList.map((s) => s.name),

src/utils/materials.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
22
import * as fs from 'fs';
33
import { getFileContent } from './file';
4-
import { getTemplateFilePath } from './config';
4+
import { getSyncFolder, getTemplateFilePath } from './config';
55
import {
66
rootPath,
77
snippetMaterialsPath,
@@ -31,6 +31,7 @@ export const getLocalMaterials = (
3131
notShowInCommand?: boolean;
3232
notShowInSnippetsList?: boolean;
3333
notShowInintellisense?: boolean;
34+
showInRunSnippetScript?: boolean;
3435
schema?: string;
3536
chatGPT?: {
3637
commandPrompt?: string;
@@ -184,6 +185,7 @@ export function getSnippets() {
184185
notShowInCommand?: boolean;
185186
notShowInSnippetsList?: boolean;
186187
notShowInintellisense?: boolean;
188+
showInRunSnippetScript?: boolean;
187189
schema?: string;
188190
chatGPT?: {
189191
commandPrompt?: string;
@@ -207,7 +209,7 @@ export function getSnippets() {
207209
privateMaterials: false,
208210
}));
209211
let snippetsMaterials = getLocalMaterials('snippets', snippetMaterialsPath);
210-
if (getPrivateSnippetMaterialsPath()) {
212+
if (getPrivateSnippetMaterialsPath() && getSyncFolder() !== rootPath) {
211213
const privateSnippetsMaterials = getLocalMaterials(
212214
'snippets',
213215
getPrivateSnippetMaterialsPath(),

src/webview/controllers/material.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getSyncFolder } from '../../utils/config';
12
import {
23
copyMaterialsFromTemp,
34
downloadMaterialsFromGit,
@@ -9,14 +10,15 @@ import {
910
blockMaterialsPath,
1011
getPrivateBlockMaterialsPath,
1112
materialsPath,
13+
rootPath,
1214
} from '../../utils/vscodeEnv';
1315
import { IMessage } from '../type';
1416

1517
const material = {
1618
getLocalMaterials: (message: IMessage<'blocks' | 'snippets'>) => {
1719
if (message.data === 'blocks') {
1820
let materials = getLocalMaterials('blocks', blockMaterialsPath);
19-
if (getPrivateBlockMaterialsPath()) {
21+
if (getPrivateBlockMaterialsPath() && getSyncFolder() !== rootPath) {
2022
const privateBlockMaterials = getLocalMaterials(
2123
'blocks',
2224
getPrivateBlockMaterialsPath(),

0 commit comments

Comments
 (0)