Skip to content

Commit d1734e3

Browse files
authored
Merge pull request #79 from github0null/dev
v2.15.2 revision
2 parents 30ad532 + 2e6d45a commit d1734e3

3 files changed

Lines changed: 43 additions & 33 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44

55
***
66

7-
### [v2.15.1]
8-
- 新增:支持在**源文件路径****烧录选项->程序文件** 中使用**变量**. 暂支持以下变量:
9-
- `OutDir`: 输出目录
10-
- `ProjectName`: 项目名
11-
- `ExecutableName`: 输出的可执行文件路径,不含后缀
12-
- `ProjectRoot`: 项目根目录
7+
### [v2.15.2] (revision)
8+
- **修复:v2.15.1 更新增加了源文件路径变量支持,导致打开项目时加载速度过慢的问题**
9+
- 优化:当开启 VT100 终端颜色失败时,自动禁用编译输出的关键字高亮(可通过向 Builder.AdditionalCommandLine 设置添加 `-force-color` 强制开启高亮)
10+
***
11+
12+
### [v2.15.1] (revision)
13+
- 新增:支持在**源文件路径****烧录选项->程序文件** 中使用**变量**(不区分大小写). 暂支持以下变量:
14+
- `$(OutDir)`: 输出目录
15+
- `$(ProjectName)`: 项目名
16+
- `$(ExecutableName)`: 输出的可执行文件路径,不含后缀
17+
- `$(ProjectRoot)`: 项目根目录
1318
- `项目设置->环境变量` 中的变量(变量名必须只包含字母,数字或下划线)
1419
- 修复:状态栏 **打开串口命令失效**
1520
- 修复:sdcc 错误输出高亮匹配失效

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"homepage": "https://github.com/github0null/eide/blob/master/README.md",
2828
"license": "MIT",
2929
"description": "An embedded development environment for 8051/STM8/Cortex-M/RISC-V",
30-
"version": "2.15.1",
30+
"version": "2.15.2",
3131
"engines": {
3232
"vscode": "^1.60.0"
3333
},

src/EIDEProject.ts

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,15 +1328,15 @@ export abstract class AbstractProject {
13281328
return [];
13291329
}
13301330

1331-
getEnvFile(): File {
1331+
getEnvFile(notInitFile?: boolean): File {
13321332

13331333
const prjConfig = this.GetConfiguration();
13341334
const targetName = prjConfig.config.mode.toLowerCase();
13351335

13361336
const envFilePath = `${this.getEideDir().path}${File.sep}${targetName}.env.ini`;
13371337
const envFile = new File(envFilePath);
13381338

1339-
if (!envFile.IsFile()) {
1339+
if (!notInitFile && !envFile.IsFile()) {
13401340
const defTxt: string[] = [
13411341
`###########################################################`,
13421342
`# project environment variables`,
@@ -1361,37 +1361,42 @@ export abstract class AbstractProject {
13611361
return envFile;
13621362
}
13631363

1364+
private env_lastGetTime: number = 0;
1365+
private env_lastReadTime: number = 0;
1366+
private env_lastRawEnvObj: { [name: string]: any } | undefined;
13641367
getProjectEnv(): { [name: string]: any } | undefined {
1368+
try {
13651369

1366-
const envs = this.getRawEnv();
1367-
if (envs == undefined) { return; }
1368-
1369-
// remove none-string obj
1370-
for (const key in envs) {
1371-
if (typeof envs[key] == 'object' ||
1372-
Array.isArray(envs[key]) ||
1373-
key.includes(' ')) {
1374-
delete envs[key];
1370+
// limit read interval (150 ms), increase speed
1371+
if (this.env_lastRawEnvObj != undefined &&
1372+
Date.now() - this.env_lastGetTime < 150) {
1373+
return this.env_lastRawEnvObj;
13751374
}
1376-
}
1377-
1378-
// return env objects
1379-
return envs;
1380-
}
13811375

1382-
private lastReadTime: number = 0;
1383-
private lastRawEnvObj: { [name: string]: any } | undefined;
1384-
private getRawEnv(): { [name: string]: any } | undefined {
1385-
try {
1386-
const envFile = this.getEnvFile();
1376+
// is env need update ?
1377+
const envFile = this.getEnvFile(true);
13871378
if (envFile.IsFile()) {
13881379
const lastMdTime = fs.statSync(envFile.path).mtimeMs;
1389-
if (this.lastRawEnvObj == undefined ||
1390-
lastMdTime > this.lastReadTime) { // update env
1391-
this.lastRawEnvObj = ini.parse(envFile.Read());
1392-
this.lastReadTime = fs.statSync(envFile.path).mtimeMs;
1380+
if (this.env_lastRawEnvObj == undefined ||
1381+
lastMdTime > this.env_lastReadTime) {
1382+
1383+
// update env
1384+
this.env_lastRawEnvObj = ini.parse(envFile.Read());
1385+
this.env_lastReadTime = lastMdTime;
1386+
1387+
// delete non-string obj
1388+
for (const key in this.env_lastRawEnvObj) {
1389+
if (typeof this.env_lastRawEnvObj[key] == 'object' ||
1390+
Array.isArray(this.env_lastRawEnvObj[key]) ||
1391+
key.includes(' ')) {
1392+
delete this.env_lastRawEnvObj[key];
1393+
}
1394+
}
13931395
}
1394-
return this.lastRawEnvObj;
1396+
1397+
// return env objects
1398+
this.env_lastGetTime = Date.now();
1399+
return this.env_lastRawEnvObj;
13951400
}
13961401
} catch (error) {
13971402
GlobalEvent.emit('msg', ExceptionToMessage(error, 'Hidden'));

0 commit comments

Comments
 (0)