Skip to content

Commit 669d0be

Browse files
committed
feat: add buttons to move to prev and next bookmark
1 parent 7b4f22a commit 669d0be

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/extensionsIntegrated/Bookmarks/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,21 @@ define(function (require, exports, module) {
88

99
// command ids
1010
const CMD_TOGGLE_BOOKMARK = "bookmarks.toggleBookmark";
11+
const CMD_NEXT_BOOKMARK = "bookmarks.nextBookmark";
12+
const CMD_PREV_BOOKMARK = "bookmarks.prevBookmark";
1113

1214
// default keyboard shortcuts
1315
const TOGGLE_BOOKMARK_KB_SHORTCUT = "Ctrl-Alt-B";
16+
const NEXT_BOOKMARK_KB_SHORTCUT = "Ctrl-Alt-N";
17+
const PREV_BOOKMARK_KB_SHORTCUT = "Ctrl-Alt-P";
1418

1519
/**
1620
* This function is responsible for registering all the required commands
1721
*/
1822
function _registerCommands() {
1923
CommandManager.register(Strings.TOGGLE_BOOKMARK, CMD_TOGGLE_BOOKMARK, Bookmarks.toggleBookmark);
24+
CommandManager.register(Strings.GOTO_NEXT_BOOKMARK, CMD_NEXT_BOOKMARK, Bookmarks.goToNextBookmark);
25+
CommandManager.register(Strings.GOTO_PREV_BOOKMARK, CMD_PREV_BOOKMARK, Bookmarks.goToPrevBookmark);
2026
}
2127

2228
/**
@@ -27,6 +33,8 @@ define(function (require, exports, module) {
2733
navigateMenu.addMenuDivider(); // add a line to separate the other items from the bookmark ones
2834

2935
navigateMenu.addMenuItem(CMD_TOGGLE_BOOKMARK, TOGGLE_BOOKMARK_KB_SHORTCUT);
36+
navigateMenu.addMenuItem(CMD_NEXT_BOOKMARK, NEXT_BOOKMARK_KB_SHORTCUT);
37+
navigateMenu.addMenuItem(CMD_PREV_BOOKMARK, PREV_BOOKMARK_KB_SHORTCUT);
3038
}
3139

3240
function init() {

src/extensionsIntegrated/Bookmarks/src/bookmarks.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ define(function (require, exports, module) {
1313
/**
1414
* This function toggles a bookmark on a specific line
1515
*
16+
* @private
1617
* @param {Editor} editor - The current editor instance
1718
* @param {number} line - The line number to toggle bookmark on
1819
*/
19-
function toggleLineBookmark(editor, line) {
20+
function _toggleLineBookmark(editor, line) {
2021
if (Helper.hasBookmark(editor, line, GUTTER_NAME)) {
2122
editor.setGutterMarker(line, GUTTER_NAME, "");
2223
} else {
@@ -38,9 +39,19 @@ define(function (require, exports, module) {
3839

3940
// process each unique line
4041
uniqueLines.forEach((line) => {
41-
toggleLineBookmark(editor, line);
42+
_toggleLineBookmark(editor, line);
4243
});
4344
}
4445

46+
function goToNextBookmark() {
47+
//
48+
}
49+
50+
function goToPrevBookmark() {
51+
//
52+
}
53+
4554
exports.toggleBookmark = toggleBookmark;
55+
exports.goToNextBookmark = goToNextBookmark;
56+
exports.goToPrevBookmark = goToPrevBookmark;
4657
});

0 commit comments

Comments
 (0)