diff --git a/newt-vscode/src/abbrev.ts b/newt-vscode/src/abbrev.ts index 2edf5b6..8294dd6 100644 --- a/newt-vscode/src/abbrev.ts +++ b/newt-vscode/src/abbrev.ts @@ -11,5 +11,8 @@ export const ABBREV: Record = { "\\>": "⟩", "\\_0": "₀", "\\_1": "₁", + "\\_2": "₂", + "\\_3": "₃", + "\\neg": "¬", "\\bN": "ℕ" }; diff --git a/newt-vscode/src/extension.ts b/newt-vscode/src/extension.ts index 1f7087a..41587af 100644 --- a/newt-vscode/src/extension.ts +++ b/newt-vscode/src/extension.ts @@ -32,9 +32,9 @@ export function activate(context: vscode.ExtensionContext) { const lastChange = changes[changes.length - 1]; const text = lastChange.text; - + console.log("lastChange", lastChange) // Check if the last change is a potential shortcut trigger - if (!text || !" ')\\".includes(text)) return; + if (!text || !( " ')\\".includes(text) || text.startsWith('\n'))) return; const document = editor.document; const position = lastChange.range.end; diff --git a/playground/src/cmeditor.ts b/playground/src/cmeditor.ts index efae07e..3870436 100644 --- a/playground/src/cmeditor.ts +++ b/playground/src/cmeditor.ts @@ -169,9 +169,10 @@ export class CMEditor implements AbstractEditor { ])), EditorView.updateListener.of((update) => { let doc = update.state.doc; - + console.log('update', update) update.changes.iterChanges((fromA, toA, fromB, toB, inserted) => { - if (" ')\\_".includes(inserted.toString())) { + console.log('inserted', inserted) + if (" ')\\_".includes(inserted.toString()) || inserted.lines > 1) { console.log("changes", update.changes, update.changes.desc); let line = doc.lineAt(fromA); let e = fromA - line.from;