11define ( function ( require , exports , module ) {
2- var PreferencesManager = require ( "preferences/PreferencesManager" ) ,
3- CommandManager = require ( "command/CommandManager" ) ,
4- Menus = require ( "command/Menus" ) ,
5- DocumentManager = require ( "document/DocumentManager" ) ,
6- EditorManager = require ( "editor/EditorManager" ) ,
7- _ = require ( "thirdparty/lodash" ) ;
8-
92 const AppInit = require ( "utils/AppInit" ) ;
3+ const PreferencesManager = require ( "preferences/PreferencesManager" ) ;
4+ const CommandManager = require ( "command/CommandManager" ) ;
5+ const Menus = require ( "command/Menus" ) ;
6+ const DocumentManager = require ( "document/DocumentManager" ) ;
7+ const EditorManager = require ( "editor/EditorManager" ) ;
8+ const Strings = require ( "strings" ) ;
9+ const _ = require ( "thirdparty/lodash" ) ;
1010
11- var BookmarksView = require ( "./bookmarksView" ) . BookmarksView ;
12-
13- /** @const {string} Extension Command ID */
14- var MY_MODULENAME = "bracketsEditorBookmarks" ;
15- var CMD_TOGGLE_BOOKMARK = "bracketsEditorBookmarks.toggleBookmark" ,
16- CMD_GOTO_NEXT_BOOKMARK = "bracketsEditorBookmarks.gotoNextBookmark" ,
17- CMD_GOTO_PREV_BOOKMARK = "bracketsEditorBookmarks.gotoPrevBookmark" ,
18- CMD_TOGGLE_BOOKKMARK_VIEW = "bracketsEditorBookmarks.toggleBookmarksPanel" ;
11+ const BookmarksView = require ( "./bookmarksView" ) . BookmarksView ;
1912
20- const ExtensionStrings = {
21- TOGGLE_BOOKMARK : "Toggle Bookmark" ,
22- GOTO_PREV_BOOKMARK : "Go to previous Bookmark" ,
23- GOTO_NEXT_BOOKMARK : "Go to next Bookmark" ,
24- TOGGLE_BOOKMARKS_PANEL : "Toggle Bookmarks panel"
25- } ;
13+ // command IDs
14+ const MY_MODULENAME = "bracketsEditorBookmarks" ;
15+ const CMD_TOGGLE_BOOKMARK = "bracketsEditorBookmarks.toggleBookmark" ;
16+ const CMD_GOTO_NEXT_BOOKMARK = "bracketsEditorBookmarks.gotoNextBookmark" ;
17+ const CMD_GOTO_PREV_BOOKMARK = "bracketsEditorBookmarks.gotoPrevBookmark" ;
18+ const CMD_TOGGLE_BOOKKMARK_VIEW = "bracketsEditorBookmarks.toggleBookmarksPanel" ;
2619
27- /* Our extension's preferences */
28- var prefs = PreferencesManager . getExtensionPrefs ( MY_MODULENAME ) ;
20+ const prefs = PreferencesManager . getExtensionPrefs ( MY_MODULENAME ) ;
2921
3022 // Bookmarks Data Model
31- var _bookmarks = { } ;
32-
23+ const _bookmarks = { } ;
3324 // Bookmarks Panel
34- var _bookmarksPanel = null ;
25+ let _bookmarksPanel = null ;
3526
3627 /**
3728 * Saves bookmarks to the data model for the specified editor instance
38- * @param {Editor= } editor - brackets editor instance. current editor if null
29+ *
30+ * @param {Editor } editor - the editor instance
3931 * @return {?Array.<Number> } array of cached bookmarked line numbers
4032 */
4133 function saveBookmarks ( editor ) {
4234 if ( ! editor ) {
4335 editor = EditorManager . getCurrentFullEditor ( ) ;
4436 }
4537 if ( editor ) {
46- var i ,
38+ let i ,
4739 fullPath = editor . document . file . fullPath ,
4840 cm = editor . _codeMirror ,
4941 lineCount = cm . doc . lineCount ( ) ,
5042 bookmarkedLines = [ ] ;
5143
5244 for ( i = 0 ; i < lineCount ; i ++ ) {
53- var lineInfo = cm . lineInfo ( i ) ;
45+ let lineInfo = cm . lineInfo ( i ) ;
5446
5547 if ( lineInfo . wrapClass && lineInfo . wrapClass . indexOf ( "bookmark" ) >= 0 ) {
5648 bookmarkedLines . push ( i ) ;
@@ -75,14 +67,15 @@ define(function (require, exports, module) {
7567
7668 /**
7769 * Updates bookmarks for the current editor if necessary
78- * @param {Editor= } editor - brackets editor instance. current editor if null
70+ *
71+ * @param {Editor } editor - the editor instance
7972 * @return {Boolean } true if there are bookmarks for the current editor, false if not
8073 */
8174 function updateBookmarksForCurrentEditor ( ) {
82- var result = false ,
75+ let result = false ,
8376 editor = EditorManager . getCurrentFullEditor ( ) ;
8477 if ( editor ) {
85- var fullPath = editor . document . file . fullPath ,
78+ let fullPath = editor . document . file . fullPath ,
8679 bm = _bookmarks [ fullPath ] ;
8780
8881 // if there was already data then we
@@ -106,7 +99,8 @@ define(function (require, exports, module) {
10699 * (for traversal or to update the bookmarks panel),
107100 * updateBookmarksForCurrentEditor is called which updates
108101 * incrementally the bookmarks for the current file
109- * @param {!Editor } editor - brackets editor instance
102+ *
103+ * @param {!Editor } editor - the editor instance
110104 */
111105 function resetBookmarks ( editor ) {
112106 if ( editor ) {
@@ -117,14 +111,15 @@ define(function (require, exports, module) {
117111
118112 /**
119113 * Loads the cached bookmarks into the specified editor instance
120- * @param {Editor= } editor - brackets editor instance. current editor if null
114+ *
115+ * @param {Editor } editor - brackets editor instance. current editor if null
121116 */
122117 function loadBookmarks ( editor ) {
123118 if ( ! editor ) {
124119 editor = EditorManager . getCurrentFullEditor ( ) ;
125120 }
126121 if ( editor ) {
127- var cm = editor . _codeMirror ,
122+ let cm = editor . _codeMirror ,
128123 bm = _bookmarks [ editor . document . file . fullPath ] ;
129124
130125 if ( bm ) {
@@ -139,10 +134,11 @@ define(function (require, exports, module) {
139134
140135 /**
141136 * Removes all bookmarks from the editor
137+ *
142138 * @param {!Editor } editor - brackets editor instance.
143139 */
144140 function clearBookmarks ( editor ) {
145- var i ,
141+ let i ,
146142 cm = editor . _codeMirror ,
147143 lineCount = cm . doc . lineCount ( ) ;
148144
@@ -170,6 +166,7 @@ define(function (require, exports, module) {
170166
171167 /**
172168 * Reloads the bookmark model, clearing the current bookmarks
169+ *
173170 * @param {!Editor } editor - brackets editor instance.
174171 */
175172 function reloadModel ( ) {
@@ -193,26 +190,27 @@ define(function (require, exports, module) {
193190
194191 /**
195192 * Moves the cursor position of the current editor to the next bookmark
193+ *
196194 * @param {!Editor } editor - brackets editor instance
197195 */
198196 function gotoNextBookmark ( forward ) {
199197 if ( updateBookmarksForCurrentEditor ( ) ) {
200- var editor = EditorManager . getCurrentFullEditor ( ) ,
198+ let editor = EditorManager . getCurrentFullEditor ( ) ,
201199 cursor = editor . getCursorPos ( ) ,
202200 bm = _bookmarks [ editor . document . file . fullPath ] ;
203201
204- var doJump = function ( lineNo ) {
202+ let doJump = function ( lineNo ) {
205203 editor . setCursorPos ( lineNo , 0 ) ;
206204
207- var cm = editor . _codeMirror ;
205+ let cm = editor . _codeMirror ;
208206 cm . addLineClass ( lineNo , "wrap" , "bookmark-notify" ) ;
209207 setTimeout ( function ( ) {
210208 cm . removeLineClass ( lineNo , "wrap" , "bookmark-notify" ) ;
211209 } , 100 ) ;
212210 } ;
213211
214212 // find next bookmark
215- var index ;
213+ let index ;
216214 for (
217215 index = forward ? 0 : bm . length - 1 ;
218216 forward ? index < bm . length : index >= 0 ;
@@ -251,9 +249,9 @@ define(function (require, exports, module) {
251249 * Toogles the bookmarked state of the current line of the current editor
252250 */
253251 function toggleBookmark ( ) {
254- var editor = EditorManager . getCurrentFullEditor ( ) ;
252+ let editor = EditorManager . getCurrentFullEditor ( ) ;
255253 if ( editor ) {
256- var cursor = editor . getCursorPos ( ) ,
254+ let cursor = editor . getCursorPos ( ) ,
257255 lineNo = cursor . line ,
258256 cm = editor . _codeMirror ,
259257 lineInfo = cm . lineInfo ( cursor . line ) ;
@@ -269,6 +267,7 @@ define(function (require, exports, module) {
269267
270268 /**
271269 * Creates the bookmarks panel if it's truly needed
270+ *
272271 * @param {Boolean } panelRequired - true if panel is required. False if not
273272 */
274273 function createBookmarksPanelIfNecessary ( panelRequired ) {
@@ -283,6 +282,7 @@ define(function (require, exports, module) {
283282
284283 /**
285284 * Shows the bookmarks panel
285+ *
286286 * @param {Boolean } show - true to show the panel, false to hide it
287287 * @param {{show:string=}= } options - undefined, {show: undefined|"opened"|"project"|"all"}, defaults to "opened"
288288 */
@@ -333,32 +333,20 @@ define(function (require, exports, module) {
333333
334334 AppInit . appReady ( function ( ) {
335335 // register our commands
336- CommandManager . register ( ExtensionStrings . TOGGLE_BOOKMARK , CMD_TOGGLE_BOOKMARK , toggleBookmark ) ;
337- CommandManager . register (
338- ExtensionStrings . GOTO_PREV_BOOKMARK ,
339- CMD_GOTO_PREV_BOOKMARK ,
340- _ . partial ( gotoNextBookmark , false )
341- ) ;
342- CommandManager . register (
343- ExtensionStrings . GOTO_NEXT_BOOKMARK ,
344- CMD_GOTO_NEXT_BOOKMARK ,
345- _ . partial ( gotoNextBookmark , true )
346- ) ;
336+ CommandManager . register ( Strings . TOGGLE_BOOKMARK , CMD_TOGGLE_BOOKMARK , toggleBookmark ) ;
337+ CommandManager . register ( Strings . GOTO_PREV_BOOKMARK , CMD_GOTO_PREV_BOOKMARK , _ . partial ( gotoNextBookmark , false ) ) ;
338+ CommandManager . register ( Strings . GOTO_NEXT_BOOKMARK , CMD_GOTO_NEXT_BOOKMARK , _ . partial ( gotoNextBookmark , true ) ) ;
347339
348340 // add our menu items
349- var menu = Menus . getMenu ( Menus . AppMenuBar . NAVIGATE_MENU ) ;
341+ let menu = Menus . getMenu ( Menus . AppMenuBar . NAVIGATE_MENU ) ;
350342
351343 menu . addMenuDivider ( ) ;
352- menu . addMenuItem ( CMD_TOGGLE_BOOKMARK , "Ctrl-Shift-K " ) ;
353- menu . addMenuItem ( CMD_GOTO_NEXT_BOOKMARK , "Ctrl-P " ) ;
354- menu . addMenuItem ( CMD_GOTO_PREV_BOOKMARK , "Ctrl-Shift -P" ) ;
344+ menu . addMenuItem ( CMD_TOGGLE_BOOKMARK , "Ctrl-Alt-B " ) ;
345+ menu . addMenuItem ( CMD_GOTO_NEXT_BOOKMARK , "Ctrl-Alt-N " ) ;
346+ menu . addMenuItem ( CMD_GOTO_PREV_BOOKMARK , "Ctrl-Alt -P" ) ;
355347
356348 menu = Menus . getMenu ( Menus . AppMenuBar . VIEW_MENU ) ;
357- CommandManager . register (
358- ExtensionStrings . TOGGLE_BOOKMARKS_PANEL ,
359- CMD_TOGGLE_BOOKKMARK_VIEW ,
360- toggleBookmarksPanel
361- ) ;
349+ CommandManager . register ( Strings . TOGGLE_BOOKMARKS_PANEL , CMD_TOGGLE_BOOKKMARK_VIEW , toggleBookmarksPanel ) ;
362350 menu . addMenuDivider ( ) ;
363351 menu . addMenuItem ( CMD_TOGGLE_BOOKKMARK_VIEW ) ;
364352
0 commit comments