Skip to content

Commit

Permalink
Fix test for changed representation of height change flag
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Jul 29, 2024
1 parent e81ba20 commit 3646cd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export {lineNumbers, highlightActiveLineGutter, gutter, gutters, GutterMarker,
gutterLineClass, lineNumberMarkers} from "./gutter"
export {highlightWhitespace, highlightTrailingWhitespace} from "./highlight-space"

import {HeightMap, HeightOracle, MeasuredHeights, QueryType} from "./heightmap"
import {HeightMap, HeightOracle, MeasuredHeights, QueryType, clearHeightChangeFlag, heightChangeFlag} from "./heightmap"
import {ChangedRange} from "./extension"
import {computeOrder, moveVisually} from "./bidi"
/// @internal
export const __test = {HeightMap, HeightOracle, MeasuredHeights, QueryType, ChangedRange, computeOrder, moveVisually}
export const __test = {HeightMap, HeightOracle, MeasuredHeights, QueryType, ChangedRange, computeOrder,
moveVisually, clearHeightChangeFlag, getHeightChangeFlag: () => heightChangeFlag}
8 changes: 4 additions & 4 deletions test/test-heightmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Decoration, WidgetType, BlockType, BlockInfo, __test} from "@codemirror/
import {Text} from "@codemirror/state"
import ist from "ist"

const {HeightMap, HeightOracle, MeasuredHeights, QueryType, ChangedRange} = __test
const {HeightMap, HeightOracle, MeasuredHeights, QueryType, ChangedRange, clearHeightChangeFlag, getHeightChangeFlag} = __test

const byH = QueryType.ByHeight, byP = QueryType.ByPos

Expand Down Expand Up @@ -139,14 +139,14 @@ describe("HeightMap", () => {
ist(map.height, 61)
})

it("doesn't set the heightChanged bit for small within-line replacements", () => {
it("doesn't set the heightChanged flag for small within-line replacements", () => {
let text = doc(10, 10, 10), oracle = o(text)
let map = mk(text, []).updateHeight(oracle, 0, false, new MeasuredHeights(0, [12, 12, 12]))
let newText = text.replace(21, 21, Text.of(["!"]))
map = map.applyChanges([], text, oracle.setDoc(newText), [new ChangedRange(21, 21, 21, 22)])
oracle.heightChanged = false
clearHeightChangeFlag()
map = map.updateHeight(oracle, 0, false, new MeasuredHeights(0, [12, 12, 12]))
ist(oracle.heightChanged, false)
ist(getHeightChangeFlag(), false)
})

it("can update lines across the tree", () => {
Expand Down

0 comments on commit 3646cd9

Please sign in to comment.