-
-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathQuickOpenHelper.js
More file actions
71 lines (62 loc) · 2.6 KB
/
Copy pathQuickOpenHelper.js
File metadata and controls
71 lines (62 loc) · 2.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* GNU AGPL-3.0 License
*
* Copyright (c) 2021 - present core.ai . All rights reserved.
* Original work Copyright (c) 2016 - 2021 Adobe Systems Incorporated. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
* for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
*
*/
// @INCLUDE_IN_API_DOCS
define(function (require, exports, module) {
var EditorManager = require("editor/EditorManager"),
QuickOpen = require("search/QuickOpen"),
DocumentManager = require("document/DocumentManager"),
StringMatch = require("utils/StringMatch");
/**
* @param {string} query what the user is searching for
* @param {boolean} returns true if this plug-in wants to provide results for this query
*/
function match(query) {
return (query[0] === "@");
}
/**
* Scroll to the selected item in the current document (unless no query string entered yet,
* in which case the topmost list item is irrelevant)
* @param {?SearchResult} selectedItem
* @param {string} query
* @param {boolean} explicit False if this is only highlighted due to being at top of list after search()
*/
function itemFocus(selectedItem, query, explicit) {
if (!selectedItem || (query.length < 2 && !explicit)) {
return;
}
var fileLocation = selectedItem.fileLocation;
var from = {line: fileLocation.line, ch: fileLocation.chFrom};
var to = {line: fileLocation.line, ch: fileLocation.chTo};
EditorManager.getCurrentFullEditor().setSelection(from, to, true);
}
/**
* Scroll to the selected item in the current document (unless no query string entered yet,
* in which case the topmost list item is irrelevant)
* @param {?SearchResult} selectedItem
* @param {string} query
*/
function itemSelect(selectedItem, query) {
itemFocus(selectedItem, query, true);
}
exports.match = match;
exports.itemFocus = itemFocus;
exports.itemSelect = itemSelect;
});