Skip to content

Commit baa556b

Browse files
committed
refactor: git extension less to single file to improve load speed
1 parent 195b1b5 commit baa556b

File tree

15 files changed

+1533
-1732
lines changed

15 files changed

+1533
-1732
lines changed

src/extensions/default/Git/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ define(function (require, exports, module) {
3131
require(modules);
3232

3333
// Load CSS
34-
ExtensionUtils.loadStyleSheet(module, "styles/brackets-git.less");
34+
ExtensionUtils.loadStyleSheet(module, "styles/git-styles.less");
3535

3636
AppInit.appReady(function () {
3737
Main.init().then((enabled)=>{

src/extensions/default/Git/src/Panel.js

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -601,54 +601,60 @@ define(function (require, exports) {
601601
let totalFiles = gitStatusResults.length,
602602
filesDone = 0;
603603

604+
function showProgress() {
605+
const $progressBar = $dialog.find('.accordion-progress-bar-inner');
606+
if ($progressBar.length) {
607+
$progressBar[0].style.width = `${filesDone/totalFiles*100}%`;
608+
}
609+
if(filesDone === totalFiles){
610+
$dialog.find('.accordion-progress-bar').addClass("forced-inVisible");
611+
}
612+
const progressString = StringUtils.format(Strings.CODE_INSPECTION_DONE_FILES, filesDone, totalFiles);
613+
$dialog.find(".lint-errors").html(progressString);
614+
}
615+
604616
const codeInspectionPromises = gitStatusResults.map(function (fileObj) {
605617
const isDeleted = fileObj.status.indexOf(Git.FILE_STATUS.DELETED) !== -1;
618+
if(isDeleted){
619+
filesDone++;
620+
showProgress();
621+
return;
622+
}
606623

607624
// Do a code inspection for the file, if it was not deleted
608-
if (!isDeleted) {
609-
return new Promise((resolve) => {
610-
// Delay lintFile execution to give the event loop some breathing room
611-
setTimeout(() => {
612-
lintFile(fileObj.file)
613-
.catch(function () {
614-
return [
615-
{
616-
provider: { name: "See console [F12] for details" },
617-
result: {
618-
errors: [
619-
{
620-
pos: { line: 0, ch: 0 },
621-
message: "CodeInspection failed to execute for this file."
622-
}
623-
]
624-
}
625+
return new Promise((resolve) => {
626+
// Delay lintFile execution to give the event loop some breathing room
627+
setTimeout(() => {
628+
lintFile(fileObj.file)
629+
.catch(function () {
630+
return [
631+
{
632+
provider: { name: "See console [F12] for details" },
633+
result: {
634+
errors: [
635+
{
636+
pos: { line: 0, ch: 0 },
637+
message: "CodeInspection failed to execute for this file."
638+
}
639+
]
625640
}
626-
];
627-
})
628-
.then(function (result) {
629-
if (result) {
630-
lintResults.push({
631-
filename: fileObj.file,
632-
result: result
633-
});
634-
}
635-
resolve();
636-
}).finally(()=>{
637-
filesDone++;
638-
const $progressBar = $dialog.find('.accordion-progress-bar-inner');
639-
if ($progressBar.length) {
640-
$progressBar[0].style.width = `${filesDone/totalFiles*100}%`;
641-
}
642-
if(filesDone === totalFiles){
643-
$dialog.find('.accordion-progress-bar').addClass("forced-inVisible");
644641
}
645-
const progressString = StringUtils.format(Strings.CODE_INSPECTION_DONE_FILES, filesDone, totalFiles);
646-
$dialog.find(".lint-errors").html(progressString);
647-
648-
});
649-
}, 0); // Delay of 0ms to defer to the next tick of the event loop
650-
});
651-
}
642+
];
643+
})
644+
.then(function (result) {
645+
if (result) {
646+
lintResults.push({
647+
filename: fileObj.file,
648+
result: result
649+
});
650+
}
651+
resolve();
652+
}).finally(()=>{
653+
filesDone++;
654+
showProgress();
655+
});
656+
}, 0); // Delay of 0ms to defer to the next tick of the event loop
657+
});
652658
});
653659

654660
return Promise.all(_.compact(codeInspectionPromises)).then(function () {

src/extensions/default/Git/src/dialogs/templates/push-dialog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div id="git-pull-dialog" class="git modal">
1+
<div id="git-push-dialog" class="git modal">
22
<div class="modal-header">
33
<h1 class="dialog-title">{{Strings.DIALOG_PUSH_TITLE}} &mdash; {{config.remote}}</h1>
44
</div>

0 commit comments

Comments
 (0)