From eb5fd90dc71f2065294c3b3474f2e4e06fe3af58 Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 12 Jan 2021 17:39:24 +0300 Subject: [PATCH] remember CM bookmarks on reload/revisit --- edit/edit.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/edit/edit.js b/edit/edit.js index 55b7863e..95439259 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -93,6 +93,7 @@ window.on('beforeunload', e => { sessionStore['editorScrollInfo' + editor.style.id] = JSON.stringify({ scrollY: window.scrollY, cms: editor.getEditors().map(cm => /** @namespace EditorScrollInfo */({ + bookmarks: (cm.state.sublimeBookmarks || []).map(b => b.find()), focus: cm.hasFocus(), height: cm.display.wrapper.style.height.replace('100vh', ''), parentHeight: cm.display.wrapper.parentElement.offsetHeight, @@ -136,9 +137,11 @@ window.on('beforeunload', e => { applyScrollInfo(cm, si = (editor.scrollInfo.cms || [])[0]) { if (si && si.sel) { + const bmOpts = {sublimeBookmark: true, clearWhenEmpty: false}; // copied from sublime.js cm.operation(() => { cm.setSelections(...si.sel, {scroll: false}); cm.scrollIntoView(cm.getCursor(), si.parentHeight / 2); + cm.state.sublimeBookmarks = si.bookmarks.map(b => cm.markText(b.from, b.to, bmOpts)); }); } },