Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions filebrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ async function renderSidebarHTML() {
}


protectModFileInSidebar(file.sha, file.name);

// add modified flag to file
let modified = '';
if (modifiedFiles[file.sha] &&
Expand Down Expand Up @@ -1317,6 +1319,20 @@ async function loadFileInHTML(fileEl, fileSha) {
}


const fileName = fileEl.querySelector('.name').textContent.replaceAll('\n','');

protectModFileInSidebar(fileSha, fileName);

// if file is modified
if (modifiedFiles[fileSha] && !modifiedFiles[fileSha].eclipsed &&
!fileEl.classList.contains('modified')) {

// update file in HTML
fileEl.classList.add('modified');

}


// if file is not modified; fetch from Git
if (!modifiedFiles[fileSha]) {

Expand All @@ -1325,8 +1341,6 @@ async function loadFileInHTML(fileEl, fileSha) {
startLoading();
}

const fileName = fileEl.querySelector('.name').textContent.replaceAll('\n','');

// get file from git
let resp = await git.getFile(treeLoc, fileName);

Expand Down Expand Up @@ -2933,6 +2947,36 @@ function protectUnsavedCode() {

}

function protectModFileInSidebar(fileSha, fileName) {

// if file is not modified
if (!modifiedFiles[fileSha]) {

// check if old modified file
// with same name and directory exists
const oldModFile = Object.values(modifiedFiles).filter(modFile => (modFile.dir === treeLoc.join() && modFile.name === fileName && !modFile.eclipsed))[0];

if (oldModFile) {

const oldFileSha = oldModFile.sha;

// update old modified file with new sha
oldModFile.sha = fileSha;

// save new modified file in local storage
modifiedFiles[fileSha] = oldModFile;

// delete old modified file
delete modifiedFiles[oldFileSha];

updateModFilesLS();

}

}

}

function setupEditor() {

// if code in storage
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/codeit-autolinker.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

env.attributes.href = href.replaceAll('\'','').replaceAll('"','').replaceAll('`','');
env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }';
env.attributes.title = isMac ? '⌘ + shift + click to open link' : 'Ctrl + shift + click to open link';
env.attributes.title = isMac ? '⌘ + Shift + click to open link' : 'Ctrl + Shift + click to open link';

// Silently catch any error thrown by decodeURIComponent (#1186)
try {
Expand Down
15 changes: 10 additions & 5 deletions live-view/live-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,17 +699,22 @@ if (isMobile) {
});


document.addEventListener('keydown', handleMetaP);
document.addEventListener('keydown', handleMetaR);

function handleMetaP(e) {
function handleMetaR(e) {

// detect ctrl/cmd+R
if ((e.key === 'r' || e.keyCode === 82) && isKeyEventMeta(e)) {

e.preventDefault();

liveView.classList.toggle('visible');
toggleLiveView(selectedFile);

if (selectedFile.lang == 'html' || selectedFile.lang == 'markup' ||
selectedFile.lang === 'markdown') {

liveView.classList.toggle('visible');
toggleLiveView(selectedFile);

}

}

Expand Down
2 changes: 1 addition & 1 deletion worker/client-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


// update worker name when updating worker
const WORKER_NAME = 'codeit-worker-v583';
const WORKER_NAME = 'codeit-worker-v584';


// internal paths
Expand Down