You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sh...@apache.org on 2023/04/21 14:18:36 UTC
[daffodil-vscode] branch main updated: Search Scrolling Index Lag Fixed
This is an automated email from the ASF dual-hosted git repository.
shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git
The following commit(s) were added to refs/heads/main by this push:
new e2d4072 Search Scrolling Index Lag Fixed
e2d4072 is described below
commit e2d40720df848a00bbc7e7dfbefe4abf751e65b3
Author: Robert Strickland <st...@gmail.com>
AuthorDate: Thu Apr 20 11:04:55 2023 -0500
Search Scrolling Index Lag Fixed
- Too much offset input manipulation was happening with too many
different variables before actually going to an offset. This has been
reduced to modular arithmetic on the `searchIndex`
Closes #584
---
src/svelte/src/components/dataEditor.svelte | 42 +++++++++--------------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/src/svelte/src/components/dataEditor.svelte b/src/svelte/src/components/dataEditor.svelte
index 39322cc..5256d6c 100644
--- a/src/svelte/src/components/dataEditor.svelte
+++ b/src/svelte/src/components/dataEditor.svelte
@@ -229,32 +229,13 @@ limitations under the License.
goTo($gotoOffset)
}
- function scrollSearchResults(isNext: boolean) {
- if ($searchResults.length > 0) {
- let index = $searchIndex
- if (isNext) {
- index = index + 1
- if (index >= $searchResults.length) {
- index = 0
- }
- } else {
- index = index - 1
- if (index < 0) {
- index = $searchResults.length - 1
- }
- }
- $searchIndex = index
- $gotoOffsetInput = $searchResults[index].toString($addressValue)
- goTo($gotoOffset)
- }
- }
-
- function scrollSearchNext() {
- scrollSearchResults(true)
- }
+ function updateSearchResults(offset?: number) {
+ $searchIndex = !offset
+ ? Math.abs(($searchResults.length + $searchIndex) % $searchResults.length)
+ : Math.abs(($searchResults.length + offset) % $searchResults.length)
- function scrollSearchPrev() {
- scrollSearchResults(false)
+ $gotoOffsetInput = $searchResults[$searchIndex].toString($addressValue)
+ goTo($searchResults[$searchIndex])
}
function updateLogicalDisplay(bytesPerRow) {
@@ -790,8 +771,7 @@ limitations under the License.
$searchResults = msg.data.searchResults
$searching = false
if ($searchResults.length > 0) {
- $searchIndex = 1
- scrollSearchResults(false)
+ updateSearchResults()
}
break
case MessageCommand.setUITheme:
@@ -918,12 +898,16 @@ limitations under the License.
<button
class={$UIThemeCSSClass}
id="search_prev"
- on:click={scrollSearchPrev}>Prev</button
+ on:click={() => {
+ updateSearchResults(--$searchIndex)
+ }}>Prev</button
>
<button
class={$UIThemeCSSClass}
id="search_next"
- on:click={scrollSearchNext}>Next</button
+ on:click={() => {
+ updateSearchResults(++$searchIndex)
+ }}>Next</button
>
<sub>{$searchIndex + 1} / {$searchResults.length} Results </sub>
{:else if $replacementsCount > 0}