Skip to content

Commit a7bbb06

Browse files
committed
Apply modifications to code-mirror-gutter-rs
1 parent e3dd37c commit a7bbb06

1 file changed

Lines changed: 28 additions & 10 deletions

File tree

app/utils/code-mirror-gutter-rs.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
import {combineConfig, MapMode, Facet, Extension, EditorState,
2-
RangeValue, RangeSet, RangeCursor} from "@codemirror/state"
3-
import {EditorView} from "./editorview"
4-
import {ViewPlugin, ViewUpdate} from "./extension"
5-
import {BlockType, WidgetType} from "./decoration"
6-
import {BlockInfo} from "./heightmap"
7-
import {Direction} from "./bidi"
1+
///
2+
/// Copied from https://github.com/codemirror/view/blob/6.36.2/src/gutter.ts
3+
///
4+
5+
// @ts-nocheck
6+
/* eslint-disable */
7+
8+
import { combineConfig, MapMode, Facet, type Extension, EditorState, RangeValue, RangeSet, type RangeCursor } from '@codemirror/state';
9+
import { ViewPlugin, ViewUpdate, BlockType, WidgetType, BlockInfo, Direction } from '@codemirror/view';
10+
import { EditorView } from 'codemirror';
11+
12+
// import {combineConfig, MapMode, Facet, Extension, EditorState,
13+
// RangeValue, RangeSet, RangeCursor} from "@codemirror/state"
14+
// import {EditorView} from "./editorview"
15+
// import {ViewPlugin, ViewUpdate} from "./extension"
16+
// import {BlockType, WidgetType} from "./decoration"
17+
// import {BlockInfo} from "./heightmap"
18+
// import {Direction} from "./bidi"
819

920
/// A gutter marker represents a bit of information attached to a line
1021
/// in a specific gutter. Your own custom markers have to extend this
@@ -126,9 +137,10 @@ const gutterView = ViewPlugin.fromClass(class {
126137
constructor(readonly view: EditorView) {
127138
this.prevViewport = view.viewport
128139
this.dom = document.createElement("div")
129-
this.dom.className = "cm-gutters"
140+
this.dom.className = "cm-gutters cm-gutters-rs"
130141
this.dom.setAttribute("aria-hidden", "true")
131142
this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px"
143+
this.dom.style.right = "0";
132144
this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf))
133145
for (let gutter of this.gutters) this.dom.appendChild(gutter.dom)
134146
this.fixed = !view.state.facet(unfixGutters)
@@ -139,7 +151,7 @@ const gutterView = ViewPlugin.fromClass(class {
139151
this.dom.style.position = "sticky"
140152
}
141153
this.syncGutters(false)
142-
view.scrollDOM.insertBefore(this.dom, view.contentDOM)
154+
view.scrollDOM.insertBefore(this.dom, view.contentDOM.nextSibling)
143155
}
144156

145157
update(update: ViewUpdate) {
@@ -188,7 +200,13 @@ const gutterView = ViewPlugin.fromClass(class {
188200
}
189201
}
190202
for (let cx of contexts) cx.finish()
191-
if (detach) this.view.scrollDOM.insertBefore(this.dom, after)
203+
if (detach) {
204+
if (after) {
205+
this.view.scrollDOM.insertBefore(this.dom, after)
206+
} else {
207+
this.view.scrollDOM.appendChild(this.dom)
208+
}
209+
}
192210
}
193211

194212
updateGutters(update: ViewUpdate) {

0 commit comments

Comments
 (0)