Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
- "Bridge.FS.writeFile(...)" now keeps bridge-file-version
- fixed infinite loading window with undefined file types
- you can now (dbl-)click an attribute preview to open the containing node
- removed old settings data
  • Loading branch information
solvedDev committed Jul 22, 2019
1 parent a7b35d3 commit a90122f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/renderer/components/editor_shell/JsonEditor/ObjectKey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
:as_block="false"
:meta="node_context.meta"
:node_context="node_context"

@click="(event) => $emit('mainClick', event)"
@dblclick.native="(event) => $store.state.Settings.cade_node_click ? $emit('arrowClick', event) : undefined"
/>
</span>

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/scripts/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class FileSystem {
if(typeof file_path !== "string") return;
if(!fs.statSync(file_path).isFile()) return this.loadDir(file_path);
let ext = path.extname(file_path);

let cache, file = await this.readFile(file_path);
try {
cache = await OmegaCache.load(file_path);
Expand All @@ -87,7 +88,6 @@ class FileSystem {
}



if(OmegaCache.isCacheFresh(file_path, cache, file.toString())) {
let { cache_content, format_version, file_version } = cache;
this.addAsTab(file_path, cache_content, format_version, null, file_version);
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/scripts/TabSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class TabSystem {

if(current.file_version === undefined) current.file_version = 0;
else current.file_version++;
console.log(current.file_version);

let comment_char = FileType.getCommentChar(current.file_path);

FileSystem[fsMethod](
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/scripts/editor/FileType.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ export default class FileType {
}

static getCommentChar(file_path) {
return this.getData(file_path).comment_character || "//";
try {
return this.getData(file_path).comment_character || "//";
} catch(e) {
return "//";
}

}
}
16 changes: 15 additions & 1 deletion src/renderer/scripts/plugins/Bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Provider from "../autoCompletions/Provider";
import { walkSync } from "../autoCompletions/Dynamic";
import LoadingWindow from "../../windows/LoadingWindow";
import OmegaCache from "../editor/OmegaCache";
import FileType from "../editor/FileType";

export default class Bridge {
constructor(is_module, file_path) {
Expand Down Expand Up @@ -96,7 +97,7 @@ export default class Bridge {
}

},
writeFile(path, data, cb, check=true) {
writeFile(path, data, cb, check=true, add_file_version=true) {
let folder = path.split(/\\|\//g);
folder.pop();
folder = folder.join("\\");
Expand All @@ -105,6 +106,19 @@ export default class Bridge {
fs.mkdir(Runtime.Paths.project() + folder, err => {
this.writeFile(path, data, cb, false);
});
} else if(add_file_version) {
fs.readFile(path, (err, read_file) => {
let fv;
if(err)
fv = `${FileType.getCommentChar(Runtime.Paths.project() + path)}bridge-file-version: #0\n`;
else
fv = `${FileType.getCommentChar(Runtime.Paths.project() + path)}bridge-file-version: #${OmegaCache.extractFileVersion(path, read_file.toString()) || 0}\n`;

fs.writeFile(Runtime.Paths.project() + path, fv + data, (err) => {
if(err && !cb) PluginAssert.throw(this.__file_path__, err);
else cb(err);
});
});
} else {
fs.writeFile(Runtime.Paths.project() + path, data, (err) => {
if(err && !cb) PluginAssert.throw(this.__file_path__, err);
Expand Down
1 change: 0 additions & 1 deletion src/renderer/store/data/settings

This file was deleted.

0 comments on commit a90122f

Please sign in to comment.