Commit 7453b643 authored by Tim Zallmann's avatar Tim Zallmann

Resetting of active Line + setting it for the async display functions

parent eda9e6b6
...@@ -14,6 +14,11 @@ export default { ...@@ -14,6 +14,11 @@ export default {
highlightFile() { highlightFile() {
$(this.$el).find('.file-content').syntaxHighlight(); $(this.$el).find('.file-content').syntaxHighlight();
}, },
highlightLine() {
if (Store.activeLine > -1) {
this.lineHighlighter.highlightHash(`#L${Store.activeLine}`);
}
}
}, },
mounted() { mounted() {
this.highlightFile(); this.highlightFile();
...@@ -26,10 +31,11 @@ export default { ...@@ -26,10 +31,11 @@ export default {
html() { html() {
this.$nextTick(() => { this.$nextTick(() => {
this.highlightFile(); this.highlightFile();
this.highlightLine();
}); });
}, },
activeLine() { activeLine() {
this.lineHighlighter.highlightHash(`#L${Store.activeLine}`); this.highlightLine();
}, },
}, },
}; };
......
...@@ -33,26 +33,25 @@ export default { ...@@ -33,26 +33,25 @@ export default {
// Maybe it is not in the current tree but in the opened tabs // Maybe it is not in the current tree but in the opened tabs
selectedFile = Helper.getFileFromPath(location.pathname); selectedFile = Helper.getFileFromPath(location.pathname);
} }
let lineNumber = null;
if (location.hash.indexOf('#L') > -1) lineNumber = Number(location.hash.substr(2));
if (selectedFile) { if (selectedFile) {
if (selectedFile.url !== this.activeFile.url) { if (selectedFile.url !== this.activeFile.url) {
this.fileClicked(selectedFile); this.fileClicked(selectedFile, lineNumber);
} } else {
if (location.hash.indexOf('#L') > -1) {
const lineNumber = Number(location.hash.substr(2));
if (!isNaN(lineNumber)) {
Store.setActiveLine(lineNumber); Store.setActiveLine(lineNumber);
} }
}
} else { } else {
// Not opened at all lets open new tab // Not opened at all lets open new tab
this.fileClicked({ this.fileClicked({
url: location.href, url: location.href,
}); }, lineNumber);
} }
}, },
fileClicked(clickedFile) { fileClicked(clickedFile, lineNumber) {
let file = clickedFile; let file = clickedFile;
if (file.loading) return; if (file.loading) return;
file.loading = true; file.loading = true;
...@@ -60,17 +59,20 @@ export default { ...@@ -60,17 +59,20 @@ export default {
if (file.type === 'tree' && file.opened) { if (file.type === 'tree' && file.opened) {
file = Store.removeChildFilesOfTree(file); file = Store.removeChildFilesOfTree(file);
file.loading = false; file.loading = false;
Store.setActiveLine(lineNumber);
} else { } else {
const openFile = Helper.getFileFromPath(file.url); const openFile = Helper.getFileFromPath(file.url);
if (openFile) { if (openFile) {
file.loading = false; file.loading = false;
Store.setActiveFiles(openFile); Store.setActiveFiles(openFile);
Store.setActiveLine(lineNumber);
} else { } else {
Service.url = file.url; Service.url = file.url;
Helper.getContent(file) Helper.getContent(file)
.then(() => { .then(() => {
file.loading = false; file.loading = false;
Helper.scrollTabsRight(); Helper.scrollTabsRight();
Store.setActiveLine(lineNumber);
}) })
.catch(Helper.loadingError); .catch(Helper.loadingError);
} }
......
...@@ -26,7 +26,7 @@ const RepoStore = { ...@@ -26,7 +26,7 @@ const RepoStore = {
}, },
activeFile: Helper.getDefaultActiveFile(), activeFile: Helper.getDefaultActiveFile(),
activeFileIndex: 0, activeFileIndex: 0,
activeLine: 0, activeLine: -1,
activeFileLabel: 'Raw', activeFileLabel: 'Raw',
files: [], files: [],
isCommitable: false, isCommitable: false,
...@@ -85,6 +85,7 @@ const RepoStore = { ...@@ -85,6 +85,7 @@ const RepoStore = {
if (!file.loading) Helper.updateHistoryEntry(file.url, file.pageTitle || file.name); if (!file.loading) Helper.updateHistoryEntry(file.url, file.pageTitle || file.name);
RepoStore.binary = file.binary; RepoStore.binary = file.binary;
RepoStore.setActiveLine(-1);
}, },
setFileActivity(file, openedFile, i) { setFileActivity(file, openedFile, i) {
...@@ -102,7 +103,7 @@ const RepoStore = { ...@@ -102,7 +103,7 @@ const RepoStore = {
}, },
setActiveLine(activeLine) { setActiveLine(activeLine) {
RepoStore.activeLine = activeLine; if (!isNaN(activeLine)) RepoStore.activeLine = activeLine;
}, },
setActiveToRaw() { setActiveToRaw() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment