Skip to content

Commit 9ad7381

Browse files
authored
Merge pull request #507 from github0null/dev
v3.26.5 revision
2 parents 54ae586 + 972ed86 commit 9ad7381

File tree

7 files changed

+86
-9
lines changed

7 files changed

+86
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ All notable version changes will be recorded in this file.
66

77
***
88

9+
### [v3.26.5] revision
10+
11+
**Improve**:
12+
- `Project Explorer`: Add `copyPath` context menu in explorer ui.
13+
- `Project AutoSave`: When the project file is being modified, cancel the pending save operation. This avoids accidental file overwriting.
14+
15+
***
16+
917
### [v3.26.4] revision
1018

1119
**Improve**:

package.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"homepage": "https://em-ide.com",
3737
"license": "MIT",
3838
"description": "A mcu development environment for 8051/AVR/STM8/Cortex-M/MIPS/RISC-V",
39-
"version": "3.26.4",
39+
"version": "3.26.5",
4040
"preview": false,
4141
"engines": {
4242
"vscode": "^1.67.0"
@@ -804,6 +804,14 @@
804804
"command": "_cl.eide.project.source.folder.modify.extraArgs",
805805
"title": "%eide.explorer.folder.modify.extraArgs%"
806806
},
807+
{
808+
"command": "_cl.eide.project.source.copyPath",
809+
"title": "%eide.explorer.copyPath%"
810+
},
811+
{
812+
"command": "_cl.eide.project.source.copyRelativePath",
813+
"title": "%eide.explorer.copyRelativePath%"
814+
},
807815
{
808816
"command": "_cl.eide.project.refresh",
809817
"title": "%eide.project.refresh%",
@@ -1497,6 +1505,16 @@
14971505
"when": "viewItem == FILE_ITEM || viewItem == V_FILE_ITEM && view == cl.eide.view.projects",
14981506
"group": "1_file@0"
14991507
},
1508+
{
1509+
"command": "_cl.eide.project.source.copyPath",
1510+
"when": "viewItem == FOLDER_ROOT || viewItem == FOLDER || viewItem == EXCFOLDER || viewItem == FILE_ITEM || viewItem == EXCFILE_ITEM || viewItem == V_FILE_ITEM || viewItem == V_EXCFILE_ITEM || viewItem == OUTPUT_FILE_ITEM || viewItem == V_FOLDER || viewItem == V_FOLDER_ROOT || viewItem == V_EXCFOLDER && view == cl.eide.view.projects",
1511+
"group": "2_file@0"
1512+
},
1513+
{
1514+
"command": "_cl.eide.project.source.copyRelativePath",
1515+
"when": "viewItem == FOLDER_ROOT || viewItem == FOLDER || viewItem == EXCFOLDER || viewItem == FILE_ITEM || viewItem == EXCFILE_ITEM || viewItem == V_FILE_ITEM || viewItem == V_EXCFILE_ITEM || viewItem == OUTPUT_FILE_ITEM && view == cl.eide.view.projects",
1516+
"group": "2_file@1"
1517+
},
15001518
{
15011519
"command": "_cl.eide.project.source.file.modify.extraArgs",
15021520
"when": "viewItem == FILE_ITEM || viewItem == V_FILE_ITEM && view == cl.eide.view.projects",

package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
"eide.explorer.file.compile": "Compile",
7575
"eide.explorer.file.modify.extraArgs": "Show/Modify Compiler Options",
7676
"eide.explorer.folder.modify.extraArgs": "Show/Modify Compiler Options",
77+
"eide.explorer.copyPath": "Copy Path",
78+
"eide.explorer.copyRelativePath": "Copy Relative Path",
7779

7880
"eide.source.show_cmsis_config_wizard": "CMSIS Configuration Wizard",
7981
"eide.source.show.disassembly": "Show Disassembly",

package.nls.zh-CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
"eide.explorer.file.compile": "编译",
7575
"eide.explorer.file.modify.extraArgs": "查看/修改此文件的编译选项",
7676
"eide.explorer.folder.modify.extraArgs": "查看/修改此文件夹的编译选项",
77+
"eide.explorer.copyPath": "复制路径",
78+
"eide.explorer.copyRelativePath": "复制相对路径",
7779

7880
"eide.source.show_cmsis_config_wizard": "CMSIS Configuration Wizard",
7981
"eide.source.show.disassembly": "查看反汇编",

src/EIDEProject.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,13 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
15241524
}
15251525
}
15261526

1527+
clearPendingSave() {
1528+
if (this.__saveDelayTimer) {
1529+
clearTimeout(this.__saveDelayTimer);
1530+
this.__saveDelayTimer = undefined;
1531+
}
1532+
}
1533+
15271534
InstallPack(packFile: File, reporter?: (progress?: number, message?: string) => void) {
15281535
return this.packManager.Install(packFile, reporter);
15291536
}

src/EIDEProjectExplorer.ts

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
828828
break;
829829
}
830830

831-
prj.Save(false, 1000); // save project file with a delay
831+
prj.Save(false, 2500); // save project file with a delay
832832
}
833833

834834
LoadWorkspaceProject(workspaceState: vscode.Memento) {
@@ -3589,9 +3589,9 @@ export class ProjectExplorer implements CustomConfigurationProvider {
35893589
const uid = prj.getUid();
35903590
const wsf = prj.getWorkspaceFile();
35913591

3592-
//
3592+
prj.clearPendingSave();
3593+
35933594
// disable autosave
3594-
//
35953595
this.enableAutoSave(false);
35963596

35973597
if (this.__autosaveDisableTimeoutTimer) {
@@ -3603,9 +3603,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
36033603
}, 5 * 60 * 1000, this);
36043604
}
36053605

3606-
//
3607-
// do something
3608-
//
3606+
// ask user to reload project
36093607
const msg = view_str$prompt$need_reload_project.replace('{}', prj.getProjectName());
36103608
const ans = await vscode.window.showInformationMessage(msg, 'Yes', 'No');
36113609
if (ans == 'Yes') {
@@ -3617,9 +3615,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
36173615
this.__autosaveDisableTimeoutTimer = undefined;
36183616
}
36193617

3620-
//
36213618
// enable auto save
3622-
//
36233619
this.enableAutoSave(true);
36243620
}
36253621

@@ -5414,6 +5410,48 @@ export class ProjectExplorer implements CustomConfigurationProvider {
54145410
}
54155411
}
54165412

5413+
async copyPath(type: 'abs' | 'relative', item: ProjTreeItem) {
5414+
5415+
const project = this.getProjectByTreeItem(item);
5416+
let copiedPath: string | undefined;
5417+
5418+
if (item.type === TreeItemType.FOLDER ||
5419+
item.type === TreeItemType.FOLDER_ROOT ||
5420+
item.type === TreeItemType.EXCFOLDER) {
5421+
const dir = <File>item.val.obj;
5422+
if (type === 'abs') {
5423+
copiedPath = dir.path;
5424+
} else {
5425+
copiedPath = project?.toRelativePath(dir.path) || dir.path;
5426+
}
5427+
}
5428+
else if (item.type === TreeItemType.V_FOLDER ||
5429+
item.type === TreeItemType.V_FOLDER_ROOT ||
5430+
item.type === TreeItemType.V_EXCFOLDER) {
5431+
const vinfo = <VirtualFolderInfo>item.val.obj;
5432+
copiedPath = vinfo.path;
5433+
}
5434+
else if (item.type === TreeItemType.V_FILE_ITEM ||
5435+
item.type === TreeItemType.V_EXCFILE_ITEM) {
5436+
const vinfo = <VirtualFileInfo>item.val.obj;
5437+
if (type === 'abs') {
5438+
copiedPath = project?.toAbsolutePath(vinfo.vFile.path) || vinfo.vFile.path;
5439+
} else {
5440+
copiedPath = vinfo.path;
5441+
}
5442+
}
5443+
else if (item.val.value instanceof File) { // if value is a file, use it
5444+
if (type === 'abs') {
5445+
copiedPath = item.val.value.path;
5446+
} else {
5447+
copiedPath = project?.toRelativePath(item.val.value.path) || item.val.value.path;
5448+
}
5449+
}
5450+
5451+
if (copiedPath)
5452+
vscode.env.clipboard.writeText(copiedPath);
5453+
}
5454+
54175455
private async showDisassemblyForElf(elfPath: string, prj: AbstractProject) {
54185456

54195457
try {

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ export async function activate(context: vscode.ExtensionContext) {
210210
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.file.modify.extraArgs', (item) => projectExplorer.modifyExtraCompilerArgs('file', item)));
211211
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.file.compile', (item) => projectExplorer.compileSingleFile(item)));
212212
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.folder.modify.extraArgs', (item) => projectExplorer.modifyExtraCompilerArgs('folder', item)));
213+
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.copyPath', (item) => projectExplorer.copyPath('abs', item)));
214+
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.copyRelativePath', (item) => projectExplorer.copyPath('relative', item)));
213215

214216
// file other operations
215217
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.excludeSource', (item, items) => projectExplorer.ExcludeSourceFile(item, items)));

0 commit comments

Comments
 (0)