fix(sidebar): stop sticky headers at connection boundaries
Closes #9996
This commit is contained in:
5 files changed
+46
-48
No files matched your search
@@ -55,6 +55,9 @@ describe("createFlatTreeIndex", () => {
|
||||
expect(index.nextSchemaContainerIndexByIndex[2]).toBe(4);
|
||||
expect(index.nextSchemaContainerIndexByIndex[4]).toBe(-1);
|
||||
expect(index.nextSchemaContainerIndexByIndex[9]).toBe(-1);
|
||||
expect(index.nextBoundaryIndexByIndex[1]).toBe(8);
|
||||
expect(index.nextBoundaryIndexByIndex[6]).toBe(8);
|
||||
expect(index.nextBoundaryIndexByIndex[9]).toBe(-1);
|
||||
});
|
||||
|
||||
it("keeps indexes isolated across connections without database containers", () => {
|
||||
@@ -65,6 +68,7 @@ describe("createFlatTreeIndex", () => {
|
||||
expect(index.stickyContainerIndexByIndex[2]).toBe(1);
|
||||
expect(index.stickyContainerIndexByIndex[4]).toBe(-1);
|
||||
expect(index.nextSchemaContainerIndexByIndex[1]).toBe(-1);
|
||||
expect(index.nextBoundaryIndexByIndex[1]).toBe(3);
|
||||
expect(index.flatNodeIndexById.get("table-b")).toBe(4);
|
||||
});
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ export interface FlatTreeIndex {
|
||||
stickyContainerIndexByIndex: Int32Array;
|
||||
nextDatabaseContainerIndexByIndex: Int32Array;
|
||||
nextSchemaContainerIndexByIndex: Int32Array;
|
||||
nextBoundaryIndexByIndex: Int32Array;
|
||||
}
|
||||
|
||||
interface FlatTreeIndexOptions {
|
||||
@@ -140,9 +141,11 @@ export function createFlatTreeIndex(nodes: readonly FlatTreeNode[], options: Fla
|
||||
const stickyContainerIndexByIndex = new Int32Array(nodes.length);
|
||||
const nextDatabaseContainerIndexByIndex = new Int32Array(nodes.length);
|
||||
const nextSchemaContainerIndexByIndex = new Int32Array(nodes.length);
|
||||
const nextBoundaryIndexByIndex = new Int32Array(nodes.length);
|
||||
stickyContainerIndexByIndex.fill(-1);
|
||||
nextDatabaseContainerIndexByIndex.fill(-1);
|
||||
nextSchemaContainerIndexByIndex.fill(-1);
|
||||
nextBoundaryIndexByIndex.fill(-1);
|
||||
|
||||
let databaseContainerIndex = -1;
|
||||
let schemaContainerIndex = -1;
|
||||
@@ -170,9 +173,12 @@ export function createFlatTreeIndex(nodes: readonly FlatTreeNode[], options: Fla
|
||||
|
||||
let nextDatabaseContainerIndex = -1;
|
||||
let nextSchemaContainerIndex = -1;
|
||||
let nextBoundaryIndex = -1;
|
||||
for (let index = nodes.length - 1; index >= 0; index -= 1) {
|
||||
const item = nodes[index];
|
||||
nextBoundaryIndexByIndex[index] = nextBoundaryIndex;
|
||||
if (options.isBoundary(item.type)) {
|
||||
nextBoundaryIndex = index;
|
||||
nextDatabaseContainerIndex = -1;
|
||||
nextSchemaContainerIndex = -1;
|
||||
continue;
|
||||
@@ -193,5 +199,6 @@ export function createFlatTreeIndex(nodes: readonly FlatTreeNode[], options: Fla
|
||||
stickyContainerIndexByIndex,
|
||||
nextDatabaseContainerIndexByIndex,
|
||||
nextSchemaContainerIndexByIndex,
|
||||
nextBoundaryIndexByIndex,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user