Change note separator to include a new line both at the start and end. This fixes a bug with hitting End/Home keys putting the cursor within the atomic block around the separator.

This commit is contained in:
Jonatan Heyman 2022-12-29 14:16:31 +01:00
parent fc4c7c8145
commit f1038ce696
5 changed files with 12 additions and 11 deletions

View File

@ -4,7 +4,8 @@ oj∞∞∞prutt
hejpython
f = lambda: 2 +1`;*/
export default `∞∞∞python
export default `
python
# hmm
def my_func():
print("hejsan")
@ -14,7 +15,8 @@ import {basicSetup} from "codemirror"
import {EditorView, keymap} from "@codemirror/view"
import {javascript} from "@codemirror/lang-javascript"
import {indentWithTab, insertTab, indentLess, indentMore} from "@codemirror/commands"
import {nord} from "./nord.mjs"javascript
import {nord} from "./nord.mjs"
javascript
let editor = new EditorView({
//extensions: [basicSetup, javascript()],
extensions: [

View File

@ -13,10 +13,10 @@ export const noteContent = new ExternalTokenizer((input) => {
while (true) {
let potentialLang = "";
for (let i=0; i<15; i++) {
for (let i=0; i<16; i++) {
potentialLang += String.fromCharCode(input.peek(i));
}
if (potentialLang.match(/^∞∞∞(text|javascript|json|python|html|sql|markdown|java|lezer|php)\n/g)) {
if (potentialLang.match(/^\n∞∞∞(text|javascript|json|python|html|sql|markdown|java|lezer|php)\n/g)) {
input.acceptToken(NoteContent);
return;
}

View File

@ -5,7 +5,7 @@ Note {
}
NoteDelimiter {
noteDelimiterMark NoteLanguage noteDelimiterEnter
noteDelimiterEnter noteDelimiterMark NoteLanguage noteDelimiterEnter
}

View File

@ -3,14 +3,14 @@ import {LRParser} from "@lezer/lr"
import {noteContent} from "./external-tokens.js"
export const parser = LRParser.deserialize({
version: 14,
states: "!WQQOPOOOVOPO'#C`O[OQO'#C_OOOO'#Cb'#CbQQOPOOOaOPO,58zOOOO,58y,58yOOOO-E6`-E6`OOOQ1G.f1G.f",
stateData: "f~OWPO~OTTO~OPUO~OXWO~O",
states: "!^QQOPOOOVOPO'#C`O[OQO'#C_OOOO'#Cb'#CbQQOPOOOaOPO,58zOOOO,58y,58yOOOO-E6`-E6`Of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: [0, noteContent],
topRules: {"Document":[0,2]},
tokenPrec: 0

View File

@ -43,7 +43,6 @@ class FirstNoteBlockStart extends WidgetType {
}
}
const noteBlockWidget = () => {
const decorate = (state) => {
const widgets = [];
@ -54,11 +53,11 @@ const noteBlockWidget = () => {
//console.log("found!", type.name, type.from, type.to)
let deco = Decoration.replace({
widget: type.from === 0 ? new FirstNoteBlockStart() : new NoteBlockStart(),
inclusive: false,
inclusive: true,
block: type.from === 0 ? false : true,
side: 0,
});
widgets.push(deco.range(type.from, type.from === 0 ? type.to :type.to-1));
widgets.push(deco.range(type.from === 0 ? type.from : type.from+1, type.from === 0 ? type.to : type.to-1));
}
},
mode: IterMode.IgnoreMounts,