Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Apr 19, 2024
1 parent a992708 commit cb7e8e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion frontend/components/CellInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,6 @@ export const CellInput = ({
EditorView.contentAttributes.of({ spellcheck: String(ENABLE_CM_SPELLCHECK) }),

EditorView.lineWrapping,
// Wowww this has been enabled for some time now... wonder if there are issues about this yet ;) - DRAL
awesome_line_wrapping,

// Reset diagnostics on change
Expand Down
20 changes: 8 additions & 12 deletions frontend/components/CellInput/awesome_line_wrapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,18 @@ export const awesome_line_wrapping = StateField.define({
return Decoration.none
},
update(deco, tr) {
const tabSize = tr.state.tabSize

if (!tr.docChanged && deco !== Decoration.none) return deco

let decorations = []

// TODO? Don't create new decorations when a line hasn't changed?
for (let i of _.range(0, tr.state.doc.lines)) {
let line = tr.state.doc.line(i + 1)
if (line.length === 0) continue

const indented_tabs = get_start_tabs(line.text).length
if (indented_tabs === 0) continue
const num_tabs = get_start_tabs(line.text).length
if (num_tabs === 0) continue

const characters_to_count = Math.min(indented_tabs, ARBITRARY_INDENT_LINE_WRAP_LIMIT)
const offset = characters_to_count * tabSize
const how_much_to_indent = Math.min(num_tabs, ARBITRARY_INDENT_LINE_WRAP_LIMIT)
const offset = how_much_to_indent * tr.state.tabSize

const linerwapper = Decoration.line({
attributes: {
Expand All @@ -44,15 +40,15 @@ export const awesome_line_wrapping = StateField.define({
// Need to push before the tabs one else codemirror gets madddd
decorations.push(linerwapper.range(line.from, line.from))

if (characters_to_count > 0) {
if (how_much_to_indent > 0) {
decorations.push(
Decoration.mark({
class: "awesome-wrapping-plugin-the-tabs",
}).range(line.from, line.from + characters_to_count)
}).range(line.from, line.from + how_much_to_indent)
)
}
if (indented_tabs > characters_to_count) {
for (let i of _.range(characters_to_count, indented_tabs)) {
if (num_tabs > how_much_to_indent) {
for (let i of _.range(how_much_to_indent, num_tabs)) {
decorations.push(
Decoration.replace({
widget: new ReactWidget(html`<span style=${{ opacity: 0.2 }}></span>`),
Expand Down

0 comments on commit cb7e8e6

Please sign in to comment.