File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,14 @@ export default class Trix {
3737 let { end, buffer } = res
3838 let done = false
3939 const decoder = new TextDecoder ( 'utf8' )
40+
41+ let size : number | undefined
42+ try {
43+ size = ( await this . ixFile . stat ( ) ) . size
44+ } catch ( e ) {
45+ /* do nothing */
46+ }
47+
4048 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
4149 while ( ! done ) {
4250 let foundSomething = false
@@ -74,6 +82,11 @@ export default class Trix {
7482 // if we are not done, and we haven't filled up maxResults with hits yet,
7583 // then refetch
7684 if ( resultArr . length + hits . length < this . maxResults && ! done ) {
85+ if ( size !== undefined && end > size ) {
86+ resultArr = resultArr . concat ( hits )
87+ break
88+ }
89+
7790 const res2 = await this . ixFile . read ( CHUNK_SIZE , end , opts )
7891
7992 // early break if empty response
You can’t perform that action at this time.
0 commit comments