This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathmain.coffee
More file actions
54 lines (45 loc) · 1.6 KB
/
main.coffee
File metadata and controls
54 lines (45 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{CompositeDisposable} = require 'atom'
Bookmarks = null
ReactBookmarks = null
BookmarksView = null
editorsBookmarks = null
disposables = null
module.exports =
config:
wrapBuffer:
title: 'Wrap Buffer'
description: 'When enabled, jumping to next or previous bookmark can wrap around the buffer.'
type: 'boolean'
default: true
activate: (bookmarksByEditorId) ->
editorsBookmarks = []
bookmarksView = null
disposables = new CompositeDisposable
atom.commands.add 'atom-workspace',
'bookmarks:view-all', ->
BookmarksView ?= require './bookmarks-view'
bookmarksView ?= new BookmarksView(editorsBookmarks)
bookmarksView.show()
atom.workspace.observeTextEditors (textEditor) ->
Bookmarks ?= require './bookmarks'
if state = bookmarksByEditorId[textEditor.id]
bookmarks = Bookmarks.deserialize(textEditor, state)
else
bookmarks = new Bookmarks(textEditor)
editorsBookmarks.push(bookmarks)
disposables.add textEditor.onDidDestroy ->
index = editorsBookmarks.indexOf(bookmarks)
editorsBookmarks.splice(index, 1) if index isnt -1
bookmarks.destroy()
deactivate: ->
bookmarksView?.destroy()
bookmarks.deactivate() for bookmarks in editorsBookmarks
disposables.dispose()
getBookmarkForEditor: (editor) ->
for bookmark in editorsBookmarks
return bookmark if bookmark.editor.id is editor.id
serialize: ->
bookmarksByEditorId = {}
for bookmarks in editorsBookmarks
bookmarksByEditorId[bookmarks.editor.id] = bookmarks.serialize()
bookmarksByEditorId