Skip to content

Commit 27b53fa

Browse files
committed
1.3.1 & Fixed: when open a huge directory, it will make colon slow
1 parent 05b6bc8 commit 27b53fa

7 files changed

Lines changed: 89 additions & 36 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
## Changelog
2-
- Themes Implemented
3-
- Template Implemented
4-
- Settings Panel Implemented
5-
- Hint on Sidebar
6-
- Multiple instances of same file has been fixed
2+
- Fixed: when open a huge directory, it will make colon slow

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Colon is a flexible text editor, built on [Electron](https://github.com/electron
66

77
### macOS
88

9-
Download the latest [Colon release](https://github.com/Chhekur/colon-ide/releases/download/v1.3.0/Colon-1.3.0.dmg) for mac.
9+
Download the latest [Colon release](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-1.3.1.dmg) for mac.
1010

1111
Colon will automatically update when a new release is available.
1212

1313
### Windows
1414

15-
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.3.0/Colon-Setup-1.3.0.exe) for windows.
15+
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-Setup-1.3.1.exe) for windows.
1616

1717
Colon will automatically update when a new release is available.
1818

1919
### Linux
2020

21-
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.3.0/Colon-1.3.0-x86_64.AppImage) for linux.
21+
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-1.3.1-x86_64.AppImage) for linux.
2222

2323
## License
2424

assets/js/editor.js

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,24 +347,63 @@ ipc.on('closeFile',function(event){
347347
closeCurrentFile(file);
348348
});
349349

350+
// generate valid ID from path
351+
352+
function pathToId(filepath){
353+
filepath = filepath.replace(/ /g, '_');
354+
filepath = filepath.replace(/:/g, '');
355+
let tokens = filepath.split(path.sep);
356+
let ID = '';
357+
for(let i = 0; i < tokens.length; i++){
358+
ID += tokens[i];
359+
}
360+
// console.log(ID);
361+
return ID;
362+
}
363+
364+
350365

351366
// open folder
352367
ipc.on('openFolder', function(event,structure){
353368
let response = '<ul class="file-tree"><li><a href="#"><span class = "label">' + structure.name + '</span></a><ul>';
354369
response += makeDirectoryTree(structure.children);
355370
response += '</ul>';
356371
$('#project-structure').html(response);
372+
// console.log($('#project-structure'));
357373
$(".file-tree").filetree();
358374
openProjectStructure(true);
359375
});
360376

377+
// create directory for specific Dirpath
378+
379+
function createDirectoryForSpecificDirpath(folder){
380+
// console.log(folder.getAttribute('data-path'));
381+
// console.log($('#' + pathToId(folder.getAttribute('data-path'))).length);
382+
// console.log($('#' + pathToId(folder.getAttribute('data-path'))).children());
383+
384+
if($('#' + pathToId(folder.getAttribute('data-path'))).children().length == 0){
385+
ipc.send('createDirectoryForSpecificDirpath', folder.getAttribute('data-path'));
386+
}
387+
}
388+
389+
ipc.on('getDirectroyForSpecificDirpath', function(event, structure){
390+
// console.log(structure);
391+
// console.log(structure.path);
392+
// console.log(makeDirectoryTree(structure.children));
393+
// console.log($('#' + structure.path.replace(/ /g, '_')));
394+
// console.log($('#askdfhkjashdfkjasdf'))
395+
396+
$('#' + pathToId(structure.path)).html(makeDirectoryTree(structure.children));
397+
$('#' + pathToId(structure.path)).filetree();
398+
});
361399
// create tree structure for opened folder
362400

363401
function makeDirectoryTree(structure){
364402
var response = "";
365403
structure.forEach(function(obj){
366404
if(obj.type == "folder"){
367-
response += '<li><a href="#"><span class = "label">'+ obj.name + '</span></a><ul>' + makeDirectoryTree(obj.children) + '</ul></li>';
405+
// response += '<li><a href="#"><span class = "label">'+ obj.name + '</span></a><ul>' + makeDirectoryTree(obj.children) + '</ul></li>';
406+
response += '<li><a href="#"><span class = "label" onclick = "createDirectoryForSpecificDirpath(this)" data-path = "' + obj.path + '">'+ obj.name + '</span></a><ul id = "' + pathToId(obj.path) + '"></ul></li>';
368407
}else{
369408
response += '<li data-extension = "'+obj.name+'"><a href="#"><span onclick = "openFileFromSidebar(this)" class = "label" data-name = "'+ obj.name +'" data-path = "'+ obj.path +'">' + obj.name + '</span></a></li>';
370409
}
@@ -591,19 +630,19 @@ $(".panel-middle").resizable({
591630
// create directory tree structure
592631

593632

594-
$(document).ready(function() {
595-
$(".file-tree").filetree();
596-
});
597-
var _gaq = _gaq || [];
598-
_gaq.push(['_setAccount', 'UA-36251023-1']);
599-
_gaq.push(['_setDomainName', 'jqueryscript.net']);
600-
_gaq.push(['_trackPageview']);
601-
602-
(function() {
603-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
604-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
605-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
606-
})();
633+
// $(document).ready(function() {
634+
// $(".file-tree").filetree();
635+
// });
636+
// var _gaq = _gaq || [];
637+
// _gaq.push(['_setAccount', 'UA-36251023-1']);
638+
// _gaq.push(['_setDomainName', 'jqueryscript.net']);
639+
// _gaq.push(['_trackPageview']);
640+
641+
// (function() {
642+
// var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
643+
// ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
644+
// var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
645+
// })();
607646

608647
// run program
609648
function run(){

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function createWindow () {
3131
slashes: true
3232
}))
3333
// Open the DevTools.
34-
// mainWindow.webContents.openDevTools()
34+
mainWindow.webContents.openDevTools()
3535
// Emitted when the window is closed.
3636
mainWindow.on('closed', function () {
3737
// Dereference the window object, usually you would store windows

menu/functions.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,47 @@ function openFolder(){
7171
structure = dirTree(dir[0]);
7272
// openFolderHelper(dir[0],structure);
7373
// console.log(typeof structure);
74+
// console.log(structure);
7475
mainWindow.webContents.send('openFolder',structure);
7576
}
7677
// console.log()
7778
}
7879

80+
ipc.on('createDirectoryForSpecificDirpath', function(event, folderpath){
81+
// console.log(dirTree(folderpath));
82+
mainWindow.webContents.send('getDirectroyForSpecificDirpath', dirTree(folderpath));
83+
});
84+
7985
function dirTree(filename) {
8086
var stats = fs.lstatSync(filename),
8187
info = {
8288
path: filename,
8389
name: path.basename(filename)
8490
};
85-
86-
if (stats.isDirectory()) {
87-
info.type = "folder";
88-
info.children = fs.readdirSync(filename).map(function(child) {
89-
return dirTree(path.join(filename,child));
90-
});
91-
} else {
92-
// Assuming it's a file. In real life it could be a symlink or
93-
// something else!
94-
info.type = "file";
95-
}
91+
// console.log(stats);
92+
let files = fs.readdirSync(filename);
93+
let temp_str = [];
94+
files.forEach(function(file){
95+
temp_str.push({
96+
path : path.join(filename, file),
97+
name : file,
98+
type : ((fs.lstatSync(path.join(filename, file)).isDirectory()) ? "folder" : "file")
99+
});
100+
});
101+
info.children = temp_str;
102+
// if (stats.isDirectory()) {
103+
// info.type = "folder";
104+
// // return dirTree(filename);
105+
// // info.children = fs.readdirSync(filename).map(function(child) {
106+
// // return dirTree(path.join(filename,child));
107+
// // });
108+
// } else {
109+
// // Assuming it's a file. In real life it could be a symlink or
110+
// // something else!
111+
// info.type = "file";
112+
// }
96113
// console.log(typeof info);
114+
// console.log(info);
97115
return info;
98116
}
99117

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Colon",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "A flexible text editor",
55
"author": "Harendra Chhekur <820121223505e@gmail.com>",
66
"main": "main.js",

0 commit comments

Comments
 (0)