Commit 7c9b2b04 authored by Phil Hughes's avatar Phil Hughes

order files by lastOpenedAt date even after filtering

added stopCallback to allow toggling with cmd+p when finder is open
changed implementation of mouseover
parent 4a22a97e
...@@ -16,6 +16,7 @@ export default { ...@@ -16,6 +16,7 @@ export default {
return { return {
focusedIndex: 0, focusedIndex: 0,
searchText: '', searchText: '',
mouseOver: false,
}; };
}, },
computed: { computed: {
...@@ -26,10 +27,12 @@ export default { ...@@ -26,10 +27,12 @@ export default {
if (searchText === '') return this.allBlobs.slice(0, MAX_RESULTS); if (searchText === '') return this.allBlobs.slice(0, MAX_RESULTS);
return fuzzaldrinPlus.filter(this.allBlobs, searchText, { return fuzzaldrinPlus
key: 'path', .filter(this.allBlobs, searchText, {
maxResults: MAX_RESULTS, key: 'path',
}); maxResults: MAX_RESULTS,
})
.sort((a, b) => b.lastOpenedAt - a.lastOpenedAt);
}, },
filteredBlobsLength() { filteredBlobsLength() {
return this.filteredBlobs.length; return this.filteredBlobs.length;
...@@ -61,6 +64,15 @@ export default { ...@@ -61,6 +64,15 @@ export default {
searchText() { searchText() {
this.focusedIndex = 0; this.focusedIndex = 0;
}, },
focusedIndex() {
if (!this.mouseOver) {
this.$nextTick(() => {
const el = this.$refs.virtualScrollList.$el;
el.scrollTop = this.focusedIndex * 55;
});
}
},
}, },
methods: { methods: {
...mapActions(['toggleFileFinder']), ...mapActions(['toggleFileFinder']),
...@@ -76,6 +88,7 @@ export default { ...@@ -76,6 +88,7 @@ export default {
case 38: case 38:
// UP // UP
e.preventDefault(); e.preventDefault();
this.mouseOver = false;
if (this.focusedIndex > 0) { if (this.focusedIndex > 0) {
this.focusedIndex -= 1; this.focusedIndex -= 1;
} else { } else {
...@@ -85,6 +98,7 @@ export default { ...@@ -85,6 +98,7 @@ export default {
case 40: case 40:
// DOWN // DOWN
e.preventDefault(); e.preventDefault();
this.mouseOver = false;
if (this.focusedIndex < this.filteredBlobsLength - 1) { if (this.focusedIndex < this.filteredBlobsLength - 1) {
this.focusedIndex += 1; this.focusedIndex += 1;
} else { } else {
...@@ -113,6 +127,10 @@ export default { ...@@ -113,6 +127,10 @@ export default {
this.toggleFileFinder(false); this.toggleFileFinder(false);
router.push(`/project${file.url}`); router.push(`/project${file.url}`);
}, },
onMouseOver(index) {
this.mouseOver = true;
this.focusedIndex = index;
},
}, },
}; };
</script> </script>
...@@ -157,8 +175,8 @@ export default { ...@@ -157,8 +175,8 @@ export default {
<virtual-list <virtual-list
:size="listHeight" :size="listHeight"
:remain="listShowCount" :remain="listShowCount"
:start="focusedIndex"
wtag="ul" wtag="ul"
ref="virtualScrollList"
> >
<template v-if="filteredBlobsLength"> <template v-if="filteredBlobsLength">
<li <li
...@@ -169,7 +187,9 @@ export default { ...@@ -169,7 +187,9 @@ export default {
:file="file" :file="file"
:search-text="searchText" :search-text="searchText"
:focused="index === focusedIndex" :focused="index === focusedIndex"
:index="index"
@click="openFile" @click="openFile"
@mouseover="onMouseOver"
/> />
</li> </li>
</template> </template>
......
...@@ -24,11 +24,18 @@ export default { ...@@ -24,11 +24,18 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
index: {
type: Number,
required: true,
},
}, },
methods: { methods: {
clickRow() { clickRow() {
this.$emit('click', this.file); this.$emit('click', this.file);
}, },
mouseOverRow() {
this.$emit('mouseover', this.index);
},
highlightText(text, addEllipsis) { highlightText(text, addEllipsis) {
const escapedText = escape(text); const escapedText = escape(text);
const maxText = const maxText =
...@@ -57,6 +64,7 @@ export default { ...@@ -57,6 +64,7 @@ export default {
'is-focused': focused, 'is-focused': focused,
}" }"
@click.prevent="clickRow" @click.prevent="clickRow"
@mouseover="mouseOverRow"
> >
<file-icon <file-icon
:file-name="file.name" :file-name="file.name"
......
...@@ -54,8 +54,19 @@ export default { ...@@ -54,8 +54,19 @@ export default {
Mousetrap.bind(['t', 'command+p', 'ctrl+p'], e => { Mousetrap.bind(['t', 'command+p', 'ctrl+p'], e => {
e.preventDefault(); e.preventDefault();
this.toggleFileFinder(true); this.toggleFileFinder(!this.fileFindVisible);
}); });
const originalStopCallback = Mousetrap.stopCallback;
Mousetrap.stopCallback = (e, el, combo) => {
if (combo === 't' && el.classList.contains('dropdown-input-field')) {
return true;
} else if (combo === 'command+p' || combo === 'ctrl+p') {
return false;
}
return originalStopCallback(e, el, combo);
};
}, },
methods: { methods: {
...mapActions(['toggleFileFinder']), ...mapActions(['toggleFileFinder']),
......
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