Skip to content

Commit 408f7bc

Browse files
committed
Fix bugs
1 parent 5b349b4 commit 408f7bc

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

Editor/Scripts/CodeExecutorData.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,16 @@ public class SnippetInfoSimplified
370370
public string code = null;
371371
public string mode = null;
372372
public string category = null;
373+
374+
public SnippetInfoSimplified() { }
375+
376+
public SnippetInfoSimplified(SnippetInfo snippet)
377+
{
378+
name = snippet.name;
379+
code = snippet.code;
380+
mode = snippet.mode;
381+
category = snippet.category;
382+
}
373383
}
374384

375385
#endregion

Editor/Scripts/Window/CodeExecutorWindow.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ private void DoPasteFromClipboard()
254254
}
255255

256256
/// <summary>
257-
/// 保存已选择的代码段到系统剪切板
257+
/// 保存已选择的代码段到系统剪贴板
258258
/// </summary>
259259
/// <returns></returns>
260260
private bool TrySaveSelectedSnippetsToClipboard()
@@ -264,25 +264,27 @@ private bool TrySaveSelectedSnippetsToClipboard()
264264
{
265265
return false;
266266
}
267+
SaveSnippetsToClipboard(snippets);
268+
return true;
269+
}
267270

271+
/// <summary>
272+
/// 保存代码段到系统剪贴板
273+
/// </summary>
274+
/// <param name="snippets"></param>
275+
private void SaveSnippetsToClipboard(List<SnippetInfo> snippets)
276+
{
268277
SnippetWrapper wrapper = new SnippetWrapper();
269-
foreach (SnippetInfo info in snippets)
278+
foreach (SnippetInfo snippet in snippets)
270279
{
271-
wrapper.snippets.Add(new SnippetInfoSimplified()
272-
{
273-
name = info.name,
274-
code = info.code,
275-
mode = info.mode,
276-
});
280+
wrapper.snippets.Add(new SnippetInfoSimplified(snippet));
277281
}
278-
279282
string data = JsonUtility.ToJson(wrapper, false);
280283
PipiUtility.SaveToClipboard(data);
281-
return true;
282284
}
283285

284286
/// <summary>
285-
/// 从系统剪切板中读取并添加代码段
287+
/// 从系统剪贴板中读取并添加代码段
286288
/// </summary>
287289
/// <returns></returns>
288290
private List<SnippetInfo> TryAddSnippetsFromClipboard()

0 commit comments

Comments
 (0)