1
0
mirror of https://github.com/salexdv/bsl_console.git synced 2024-12-04 10:24:50 +02:00

Merge branch 'salexdv:develop' into develop

This commit is contained in:
Sergey Starykh 2021-05-13 12:16:28 +03:00
commit 7a3efbcc21
3 changed files with 56 additions and 42 deletions

View File

@ -118,6 +118,7 @@
| `removeBookmark` | Удаление закладки из строки с указанным номером |
| `goNextBookmark` | Переход к следующей закладке |
| `goPreviousBookmark` | Переход к предыдущей закладке |
| `getBookmarks` | Возвращает массив с номерами строк, в которых установлены закладки |
## События, генерируемые редактором для 1С:Предприятия
| Событие | Описание |

View File

@ -1,5 +1,11 @@
define(['vs/editor/editor.main'], function () {
getSortedBookmarks = function () {
return new Map([...bookmarks.entries()].sort((a, b) => a[0] - b[0]));
}
getBookmarksDecorations = function () {
let bm_decorations = [];
@ -49,7 +55,7 @@ define(['vs/editor/editor.main'], function () {
goNextBookmark = function () {
let sorted_bookmarks = new Map([...bookmarks.entries()].sort());
let sorted_bookmarks = getSortedBookmarks();
if (sorted_bookmarks.size - 1 <= currentBookmark)
currentBookmark = -1;
@ -61,7 +67,7 @@ define(['vs/editor/editor.main'], function () {
goPreviousBookmark = function () {
let sorted_bookmarks = new Map([...bookmarks.entries()].sort());
let sorted_bookmarks = getSortedBookmarks();
currentBookmark--;

View File

@ -1050,6 +1050,13 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
}
getBookmarks = function () {
let sorted_bookmarks = getSortedBookmarks();
return Array.from(sorted_bookmarks.keys());
}
editor = undefined;
// Register languages
@ -1274,43 +1281,43 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
function checkBookmarksAfterNewLine() {
let line = getCurrentLine();
let prev_bookmark = bookmarks.get(line - 1);
let prev_bookmark = bookmarks.get(line - 1);
if (prev_bookmark) {
let content = getLineContent(line);
let prev_content = getLineContent(line - 1)
if (content || content == prev_content) {
prev_bookmark.range.startLineNumber = line;
prev_bookmark.range.endLineNumber = line;
bookmarks.set(line, prev_bookmark);
bookmarks.delete(line - 1);
let line_check = getLineCount();
while(line < line_check) {
let bookmark = bookmarks.get(line_check);
if (bookmark) {
bookmark.range.startLineNumber = line_check + 1;
bookmark.range.endLineNumber = line_check + 1;
bookmarks.set(line_check + 1, bookmark);
bookmarks.delete(line_check);
}
line_check--;
}
updateBookmarks(undefined);
}
}
let line_check = getLineCount();
while (line < line_check) {
let bookmark = bookmarks.get(line_check);
if (bookmark) {
bookmark.range.startLineNumber = line_check + 1;
bookmark.range.endLineNumber = line_check + 1;
bookmarks.set(line_check + 1, bookmark);
bookmarks.delete(line_check);
}
line_check--;
}
updateBookmarks(undefined);
}
function checkBookmarksAfterRemoveLine(contentChangeEvent) {
@ -1331,30 +1338,30 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
bookmarks.delete(l);
}
let line_check = range.endLineNumber;
let diff = range.endLineNumber - line;
while(line_check < getLineCount()) {
let bookmark = bookmarks.get(line_check);
if (bookmark) {
bookmark.range.startLineNumber = line_check - diff;
bookmark.range.endLineNumber = line_check - diff;
bookmarks.set(line_check - diff, bookmark);
bookmarks.delete(line_check);
}
line_check++;
}
prev_bookmark.range.startLineNumber = line;
prev_bookmark.range.endLineNumber = line;
bookmarks.set(line, prev_bookmark);
}
let line_check = range.endLineNumber;
let diff = range.endLineNumber - line;
while (line_check < getLineCount()) {
let bookmark = bookmarks.get(line_check);
if (bookmark) {
bookmark.range.startLineNumber = line_check - diff;
bookmark.range.endLineNumber = line_check - diff;
bookmarks.set(line_check - diff, bookmark);
bookmarks.delete(line_check);
}
line_check++;
}
}
}