@jupyterlab/codemirror 4.0.0-alpha.8 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/codemirror-ipythongfm.d.ts +9 -3
- package/lib/codemirror-ipythongfm.js +52 -30
- package/lib/codemirror-ipythongfm.js.map +1 -1
- package/lib/commands.d.ts +13 -0
- package/lib/commands.js +32 -0
- package/lib/commands.js.map +1 -0
- package/lib/editor.d.ts +48 -273
- package/lib/editor.js +220 -819
- package/lib/editor.js.map +1 -1
- package/lib/extension.d.ts +236 -0
- package/lib/extension.js +696 -0
- package/lib/extension.js.map +1 -0
- package/lib/extensions/customStyle.d.ts +25 -0
- package/lib/extensions/customStyle.js +51 -0
- package/lib/extensions/customStyle.js.map +1 -0
- package/lib/extensions/index.d.ts +3 -0
- package/lib/extensions/index.js +8 -0
- package/lib/extensions/index.js.map +1 -0
- package/lib/extensions/rulers.d.ts +8 -0
- package/lib/extensions/rulers.js +85 -0
- package/lib/extensions/rulers.js.map +1 -0
- package/lib/extensions/ybinding.d.ts +129 -0
- package/lib/extensions/ybinding.js +229 -0
- package/lib/extensions/ybinding.js.map +1 -0
- package/lib/factory.d.ts +15 -5
- package/lib/factory.js +53 -24
- package/lib/factory.js.map +1 -1
- package/lib/index.d.ts +7 -19
- package/lib/index.js +7 -23
- package/lib/index.js.map +1 -1
- package/lib/language.d.ts +96 -0
- package/lib/language.js +1687 -0
- package/lib/language.js.map +1 -0
- package/lib/mimetype.d.ts +3 -0
- package/lib/mimetype.js +16 -5
- package/lib/mimetype.js.map +1 -1
- package/lib/searchprovider.d.ts +219 -0
- package/lib/searchprovider.js +640 -0
- package/lib/searchprovider.js.map +1 -0
- package/lib/theme.d.ts +57 -0
- package/lib/theme.js +194 -0
- package/lib/theme.js.map +1 -0
- package/lib/token.d.ts +375 -0
- package/lib/token.js +18 -0
- package/lib/token.js.map +1 -0
- package/package.json +45 -41
- package/src/codemirror-ipythongfm.ts +109 -0
- package/src/commands.ts +34 -0
- package/src/editor.ts +783 -0
- package/src/extension.ts +890 -0
- package/src/extensions/customStyle.ts +79 -0
- package/src/extensions/index.ts +8 -0
- package/src/extensions/rulers.ts +112 -0
- package/src/extensions/ybinding.ts +295 -0
- package/src/factory.ts +100 -0
- package/src/index.ts +17 -0
- package/src/language.ts +1726 -0
- package/src/mimetype.ts +54 -0
- package/src/searchprovider.ts +813 -0
- package/src/theme.ts +219 -0
- package/src/token.ts +436 -0
- package/src/typings.d.ts +13 -0
- package/style/base.css +33 -187
- package/style/index.css +1 -7
- package/style/index.js +1 -7
- package/lib/codemirror-ipython.d.ts +0 -2
- package/lib/codemirror-ipython.js +0 -30
- package/lib/codemirror-ipython.js.map +0 -1
- package/lib/mode.d.ts +0 -82
- package/lib/mode.js +0 -150
- package/lib/mode.js.map +0 -1
- package/lib/syntaxstatus.d.ts +0 -67
- package/lib/syntaxstatus.js +0 -140
- package/lib/syntaxstatus.js.map +0 -1
- package/lib/tokens.d.ts +0 -18
- package/lib/tokens.js +0 -8
- package/lib/tokens.js.map +0 -1
- package/typings/codemirror/codemirror.d.ts +0 -227
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { StateEffect, StateField } from '@codemirror/state';
|
|
4
|
+
import { Decoration, EditorView } from '@codemirror/view';
|
|
5
|
+
import { GenericSearchProvider, TextSearchEngine } from '@jupyterlab/documentsearch';
|
|
6
|
+
import { Signal } from '@lumino/signaling';
|
|
7
|
+
/**
|
|
8
|
+
* Search provider for editors.
|
|
9
|
+
*/
|
|
10
|
+
export class EditorSearchProvider {
|
|
11
|
+
/**
|
|
12
|
+
* Constructor
|
|
13
|
+
*/
|
|
14
|
+
constructor() {
|
|
15
|
+
/**
|
|
16
|
+
* Current match index
|
|
17
|
+
*/
|
|
18
|
+
this.currentIndex = null;
|
|
19
|
+
/**
|
|
20
|
+
* Current search query
|
|
21
|
+
*/
|
|
22
|
+
this.query = null;
|
|
23
|
+
this._isActive = true;
|
|
24
|
+
this._inSelection = null;
|
|
25
|
+
this._isDisposed = false;
|
|
26
|
+
this._cmHandler = null;
|
|
27
|
+
this.currentIndex = null;
|
|
28
|
+
this._stateChanged = new Signal(this);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* CodeMirror search highlighter
|
|
32
|
+
*/
|
|
33
|
+
get cmHandler() {
|
|
34
|
+
if (!this._cmHandler) {
|
|
35
|
+
this._cmHandler = new CodeMirrorSearchHighlighter(this.editor);
|
|
36
|
+
}
|
|
37
|
+
return this._cmHandler;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Changed signal to be emitted when search matches change.
|
|
41
|
+
*/
|
|
42
|
+
get stateChanged() {
|
|
43
|
+
return this._stateChanged;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Current match index
|
|
47
|
+
*/
|
|
48
|
+
get currentMatchIndex() {
|
|
49
|
+
return this.isActive ? this.currentIndex : null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Whether the cell search is active.
|
|
53
|
+
*
|
|
54
|
+
* This is used when applying search only on selected cells.
|
|
55
|
+
*/
|
|
56
|
+
get isActive() {
|
|
57
|
+
return this._isActive;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether the search provider is disposed or not.
|
|
61
|
+
*/
|
|
62
|
+
get isDisposed() {
|
|
63
|
+
return this._isDisposed;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Number of matches in the cell.
|
|
67
|
+
*/
|
|
68
|
+
get matchesCount() {
|
|
69
|
+
return this.isActive ? this.cmHandler.matches.length : 0;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Clear currently highlighted match
|
|
73
|
+
*/
|
|
74
|
+
clearHighlight() {
|
|
75
|
+
this.currentIndex = null;
|
|
76
|
+
this.cmHandler.clearHighlight();
|
|
77
|
+
return Promise.resolve();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Dispose the search provider
|
|
81
|
+
*/
|
|
82
|
+
dispose() {
|
|
83
|
+
if (this._isDisposed) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this._isDisposed = true;
|
|
87
|
+
Signal.clearData(this);
|
|
88
|
+
if (this.isActive) {
|
|
89
|
+
this.endQuery().catch(reason => {
|
|
90
|
+
console.error(`Failed to end search query on cells.`, reason);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Set `isActive` status.
|
|
96
|
+
*
|
|
97
|
+
* #### Notes
|
|
98
|
+
* It will start or end the search
|
|
99
|
+
*
|
|
100
|
+
* @param v New value
|
|
101
|
+
*/
|
|
102
|
+
async setIsActive(v) {
|
|
103
|
+
if (this._isActive === v) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this._isActive = v;
|
|
107
|
+
if (this._isActive) {
|
|
108
|
+
if (this.query !== null) {
|
|
109
|
+
await this.startQuery(this.query, this.filters);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
await this.endQuery();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Set whether search should be limitted to specified selection.
|
|
118
|
+
*/
|
|
119
|
+
async setSearchSelection(selection) {
|
|
120
|
+
if (this._inSelection === selection) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this._inSelection = selection;
|
|
124
|
+
await this.updateCodeMirror(this.model.sharedModel.getSource());
|
|
125
|
+
this._stateChanged.emit();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Initialize the search using the provided options. Should update the UI
|
|
129
|
+
* to highlight all matches and "select" the first match.
|
|
130
|
+
*
|
|
131
|
+
* @param query A RegExp to be use to perform the search
|
|
132
|
+
* @param filters Filter parameters to pass to provider
|
|
133
|
+
*/
|
|
134
|
+
async startQuery(query, filters) {
|
|
135
|
+
this.query = query;
|
|
136
|
+
this.filters = filters;
|
|
137
|
+
// Search input
|
|
138
|
+
const content = this.model.sharedModel.getSource();
|
|
139
|
+
await this.updateCodeMirror(content);
|
|
140
|
+
this.model.sharedModel.changed.connect(this.onSharedModelChanged, this);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Stop the search and clean any UI elements.
|
|
144
|
+
*/
|
|
145
|
+
async endQuery() {
|
|
146
|
+
await this.clearHighlight();
|
|
147
|
+
await this.cmHandler.endQuery();
|
|
148
|
+
this.currentIndex = null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Highlight the next match.
|
|
152
|
+
*
|
|
153
|
+
* @returns The next match if there is one.
|
|
154
|
+
*/
|
|
155
|
+
async highlightNext(loop = true, fromCursor = false) {
|
|
156
|
+
if (this.matchesCount === 0 || !this.isActive) {
|
|
157
|
+
this.currentIndex = null;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// This starts from the cursor position if `fromCursor` is true
|
|
161
|
+
let match = await this.cmHandler.highlightNext(fromCursor);
|
|
162
|
+
if (match) {
|
|
163
|
+
this.currentIndex = this.cmHandler.currentIndex;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Note: the loop logic is only used in single-editor (e.g. file editor)
|
|
167
|
+
// provider sub-classes, notebook has it's own loop logic and ignores
|
|
168
|
+
// `currentIndex` as set here.
|
|
169
|
+
this.currentIndex = loop ? 0 : null;
|
|
170
|
+
}
|
|
171
|
+
return match;
|
|
172
|
+
}
|
|
173
|
+
return Promise.resolve(this.getCurrentMatch());
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Highlight the previous match.
|
|
177
|
+
*
|
|
178
|
+
* @returns The previous match if there is one.
|
|
179
|
+
*/
|
|
180
|
+
async highlightPrevious(loop = true, fromCursor = false) {
|
|
181
|
+
if (this.matchesCount === 0 || !this.isActive) {
|
|
182
|
+
this.currentIndex = null;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
// This starts from the cursor position if `fromCursor` is true
|
|
186
|
+
let match = await this.cmHandler.highlightPrevious(fromCursor);
|
|
187
|
+
if (match) {
|
|
188
|
+
this.currentIndex = this.cmHandler.currentIndex;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
this.currentIndex = loop ? this.matchesCount - 1 : null;
|
|
192
|
+
}
|
|
193
|
+
return match;
|
|
194
|
+
}
|
|
195
|
+
return Promise.resolve(this.getCurrentMatch());
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Replace the currently selected match with the provided text.
|
|
199
|
+
*
|
|
200
|
+
* If no match is selected, it won't do anything.
|
|
201
|
+
*
|
|
202
|
+
* The caller of this method is expected to call `highlightNext` if after
|
|
203
|
+
* calling `replaceCurrentMatch()` attribute `this.currentIndex` is null.
|
|
204
|
+
* It is necesary to let the caller handle highlighting because this
|
|
205
|
+
* method is used in composition pattern (search engine of notebook cells)
|
|
206
|
+
* and highligthing on the composer (notebook) level needs to switch to next
|
|
207
|
+
* engine (cell) with matches.
|
|
208
|
+
*
|
|
209
|
+
* @param newText The replacement text.
|
|
210
|
+
* @returns Whether a replace occurred.
|
|
211
|
+
*/
|
|
212
|
+
replaceCurrentMatch(newText, loop, options) {
|
|
213
|
+
if (!this.isActive) {
|
|
214
|
+
return Promise.resolve(false);
|
|
215
|
+
}
|
|
216
|
+
let occurred = false;
|
|
217
|
+
if (this.currentIndex !== null &&
|
|
218
|
+
this.currentIndex < this.cmHandler.matches.length) {
|
|
219
|
+
const match = this.getCurrentMatch();
|
|
220
|
+
// If cursor there is no match selected, highlight the next match
|
|
221
|
+
if (!match) {
|
|
222
|
+
this.currentIndex = null;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
this.cmHandler.matches.splice(this.currentIndex, 1);
|
|
226
|
+
this.currentIndex =
|
|
227
|
+
this.currentIndex < this.cmHandler.matches.length
|
|
228
|
+
? Math.max(this.currentIndex - 1, 0)
|
|
229
|
+
: null;
|
|
230
|
+
const substitutedText = (options === null || options === void 0 ? void 0 : options.regularExpression)
|
|
231
|
+
? match.text.replace(this.query, newText)
|
|
232
|
+
: newText;
|
|
233
|
+
const insertText = (options === null || options === void 0 ? void 0 : options.preserveCase)
|
|
234
|
+
? GenericSearchProvider.preserveCase(match.text, substitutedText)
|
|
235
|
+
: substitutedText;
|
|
236
|
+
this.model.sharedModel.updateSource(match.position, match.position + match.text.length, insertText);
|
|
237
|
+
occurred = true;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return Promise.resolve(occurred);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Replace all matches in the cell source with the provided text
|
|
244
|
+
*
|
|
245
|
+
* @param newText The replacement text.
|
|
246
|
+
* @returns Whether a replace occurred.
|
|
247
|
+
*/
|
|
248
|
+
replaceAllMatches(newText, options) {
|
|
249
|
+
if (!this.isActive) {
|
|
250
|
+
return Promise.resolve(false);
|
|
251
|
+
}
|
|
252
|
+
let occurred = this.cmHandler.matches.length > 0;
|
|
253
|
+
let src = this.model.sharedModel.getSource();
|
|
254
|
+
let lastEnd = 0;
|
|
255
|
+
const finalSrc = this.cmHandler.matches.reduce((agg, match) => {
|
|
256
|
+
const start = match.position;
|
|
257
|
+
const end = start + match.text.length;
|
|
258
|
+
const substitutedText = (options === null || options === void 0 ? void 0 : options.regularExpression)
|
|
259
|
+
? match.text.replace(this.query, newText)
|
|
260
|
+
: newText;
|
|
261
|
+
const insertText = (options === null || options === void 0 ? void 0 : options.preserveCase)
|
|
262
|
+
? GenericSearchProvider.preserveCase(match.text, substitutedText)
|
|
263
|
+
: substitutedText;
|
|
264
|
+
const newStep = `${agg}${src.slice(lastEnd, start)}${insertText}`;
|
|
265
|
+
lastEnd = end;
|
|
266
|
+
return newStep;
|
|
267
|
+
}, '');
|
|
268
|
+
if (occurred) {
|
|
269
|
+
this.cmHandler.matches = [];
|
|
270
|
+
this.currentIndex = null;
|
|
271
|
+
this.model.sharedModel.setSource(`${finalSrc}${src.slice(lastEnd)}`);
|
|
272
|
+
}
|
|
273
|
+
return Promise.resolve(occurred);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Get the current match if it exists.
|
|
277
|
+
*
|
|
278
|
+
* @returns The current match
|
|
279
|
+
*/
|
|
280
|
+
getCurrentMatch() {
|
|
281
|
+
if (this.currentIndex === null) {
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
let match = undefined;
|
|
286
|
+
if (this.currentIndex < this.cmHandler.matches.length) {
|
|
287
|
+
match = this.cmHandler.matches[this.currentIndex];
|
|
288
|
+
}
|
|
289
|
+
return match;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Callback on source change
|
|
294
|
+
*
|
|
295
|
+
* @param emitter Source of the change
|
|
296
|
+
* @param changes Source change
|
|
297
|
+
*/
|
|
298
|
+
async onSharedModelChanged(emitter, changes) {
|
|
299
|
+
if (changes.sourceChange) {
|
|
300
|
+
await this.updateCodeMirror(emitter.getSource());
|
|
301
|
+
this._stateChanged.emit();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Update matches
|
|
306
|
+
*/
|
|
307
|
+
async updateCodeMirror(content) {
|
|
308
|
+
if (this.query !== null && this.isActive) {
|
|
309
|
+
const allMatches = await TextSearchEngine.search(this.query, content);
|
|
310
|
+
if (this._inSelection) {
|
|
311
|
+
const editor = this.editor;
|
|
312
|
+
const start = editor.getOffsetAt(this._inSelection.start);
|
|
313
|
+
const end = editor.getOffsetAt(this._inSelection.end);
|
|
314
|
+
this.cmHandler.matches = allMatches.filter(match => match.position >= start && match.position <= end);
|
|
315
|
+
// A special case to always have a current match when in line selection mode.
|
|
316
|
+
if (this.cmHandler.currentIndex === null &&
|
|
317
|
+
this.cmHandler.matches.length > 0) {
|
|
318
|
+
await this.cmHandler.highlightNext(true, false);
|
|
319
|
+
}
|
|
320
|
+
this.currentIndex = this.cmHandler.currentIndex;
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
this.cmHandler.matches = allMatches;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
this.cmHandler.matches = [];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Helper class to highlight texts in a code mirror editor.
|
|
333
|
+
*
|
|
334
|
+
* Highlighted texts (aka `matches`) must be provided through
|
|
335
|
+
* the `matches` attributes.
|
|
336
|
+
*
|
|
337
|
+
* **NOTES:**
|
|
338
|
+
* - to retain the selection visibility `drawSelection` extension is needed.
|
|
339
|
+
* - highlighting starts from the cursor (if editor is focused, cursor moved,
|
|
340
|
+
* or `fromCursor` argument is set to `true`), or from last "current" match
|
|
341
|
+
* otherwise.
|
|
342
|
+
* - `currentIndex` is the (readonly) source of truth for the current match.
|
|
343
|
+
*/
|
|
344
|
+
export class CodeMirrorSearchHighlighter {
|
|
345
|
+
/**
|
|
346
|
+
* Constructor
|
|
347
|
+
*
|
|
348
|
+
* @param editor The CodeMirror editor
|
|
349
|
+
*/
|
|
350
|
+
constructor(editor) {
|
|
351
|
+
this._current = null;
|
|
352
|
+
this._cm = editor;
|
|
353
|
+
this._matches = new Array();
|
|
354
|
+
this._currentIndex = null;
|
|
355
|
+
this._highlightEffect = StateEffect.define({
|
|
356
|
+
map: (value, mapping) => {
|
|
357
|
+
const transform = (v) => ({
|
|
358
|
+
text: v.text,
|
|
359
|
+
position: mapping.mapPos(v.position)
|
|
360
|
+
});
|
|
361
|
+
return {
|
|
362
|
+
matches: value.matches.map(transform),
|
|
363
|
+
currentMatch: value.currentMatch
|
|
364
|
+
? transform(value.currentMatch)
|
|
365
|
+
: null
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
this._highlightMark = Decoration.mark({ class: 'cm-searching' });
|
|
370
|
+
this._currentMark = Decoration.mark({ class: 'jp-current-match' });
|
|
371
|
+
this._highlightField = StateField.define({
|
|
372
|
+
create: () => {
|
|
373
|
+
return Decoration.none;
|
|
374
|
+
},
|
|
375
|
+
update: (highlights, transaction) => {
|
|
376
|
+
highlights = highlights.map(transaction.changes);
|
|
377
|
+
for (let ef of transaction.effects) {
|
|
378
|
+
if (ef.is(this._highlightEffect)) {
|
|
379
|
+
const e = ef;
|
|
380
|
+
if (e.value.matches.length) {
|
|
381
|
+
highlights = highlights.update({
|
|
382
|
+
add: e.value.matches.map(m => this._highlightMark.range(m.position, m.position + m.text.length)),
|
|
383
|
+
// filter out old marks
|
|
384
|
+
filter: () => false
|
|
385
|
+
});
|
|
386
|
+
highlights = highlights.update({
|
|
387
|
+
add: e.value.currentMatch
|
|
388
|
+
? [
|
|
389
|
+
this._currentMark.range(e.value.currentMatch.position, e.value.currentMatch.position +
|
|
390
|
+
e.value.currentMatch.text.length)
|
|
391
|
+
]
|
|
392
|
+
: []
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
highlights = Decoration.none;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return highlights;
|
|
401
|
+
},
|
|
402
|
+
provide: f => EditorView.decorations.from(f)
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* The current index of the selected match.
|
|
407
|
+
*/
|
|
408
|
+
get currentIndex() {
|
|
409
|
+
return this._currentIndex;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* The list of matches
|
|
413
|
+
*/
|
|
414
|
+
get matches() {
|
|
415
|
+
return this._matches;
|
|
416
|
+
}
|
|
417
|
+
set matches(v) {
|
|
418
|
+
this._matches = v;
|
|
419
|
+
if (this._currentIndex !== null &&
|
|
420
|
+
this._currentIndex > this._matches.length) {
|
|
421
|
+
this._currentIndex = this._matches.length > 0 ? 0 : null;
|
|
422
|
+
}
|
|
423
|
+
this._highlightCurrentMatch(true);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Clear all highlighted matches
|
|
427
|
+
*/
|
|
428
|
+
clearHighlight() {
|
|
429
|
+
this._currentIndex = null;
|
|
430
|
+
this._highlightCurrentMatch();
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Clear the highlighted matches.
|
|
434
|
+
*/
|
|
435
|
+
endQuery() {
|
|
436
|
+
this._currentIndex = null;
|
|
437
|
+
this._matches = [];
|
|
438
|
+
if (this._cm) {
|
|
439
|
+
this._cm.editor.dispatch({
|
|
440
|
+
effects: this._highlightEffect.of({ matches: [], currentMatch: null })
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
return Promise.resolve();
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Highlight the next match
|
|
447
|
+
*
|
|
448
|
+
* @returns The next match if available
|
|
449
|
+
*/
|
|
450
|
+
highlightNext(fromCursor = false, doNotModifySelection = false) {
|
|
451
|
+
this._currentIndex = this._findNext(false, fromCursor);
|
|
452
|
+
this._highlightCurrentMatch(doNotModifySelection);
|
|
453
|
+
return Promise.resolve(this._currentIndex !== null
|
|
454
|
+
? this._matches[this._currentIndex]
|
|
455
|
+
: undefined);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Highlight the previous match
|
|
459
|
+
*
|
|
460
|
+
* @returns The previous match if available
|
|
461
|
+
*/
|
|
462
|
+
highlightPrevious(fromCursor = false) {
|
|
463
|
+
this._currentIndex = this._findNext(true, fromCursor);
|
|
464
|
+
this._highlightCurrentMatch();
|
|
465
|
+
return Promise.resolve(this._currentIndex !== null
|
|
466
|
+
? this._matches[this._currentIndex]
|
|
467
|
+
: undefined);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Set the editor
|
|
471
|
+
*
|
|
472
|
+
* @param editor Editor
|
|
473
|
+
*/
|
|
474
|
+
setEditor(editor) {
|
|
475
|
+
if (this._cm) {
|
|
476
|
+
throw new Error('CodeMirrorEditor already set.');
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
this._cm = editor;
|
|
480
|
+
if (this._currentIndex !== null) {
|
|
481
|
+
this._highlightCurrentMatch();
|
|
482
|
+
}
|
|
483
|
+
this._refresh();
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
_selectCurrentMatch() {
|
|
487
|
+
const match = this._current;
|
|
488
|
+
if (!match) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (!this._cm) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
const selection = this._cm.editor.state.selection.main;
|
|
495
|
+
if (selection.from === match.position &&
|
|
496
|
+
selection.to === match.position + match.text.length) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const cursor = {
|
|
500
|
+
anchor: match.position,
|
|
501
|
+
head: match.position + match.text.length
|
|
502
|
+
};
|
|
503
|
+
this._cm.editor.dispatch({
|
|
504
|
+
selection: cursor,
|
|
505
|
+
scrollIntoView: true
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
_highlightCurrentMatch(doNotModifySelection = false) {
|
|
509
|
+
if (!this._cm) {
|
|
510
|
+
// no-op
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
// Highlight the current index
|
|
514
|
+
if (this._currentIndex !== null) {
|
|
515
|
+
const match = this.matches[this._currentIndex];
|
|
516
|
+
this._current = match;
|
|
517
|
+
// Do not change selection/scroll if user is selecting
|
|
518
|
+
if (!doNotModifySelection) {
|
|
519
|
+
if (this._cm.hasFocus()) {
|
|
520
|
+
// If editor is focused we actually set the cursor on the match.
|
|
521
|
+
this._selectCurrentMatch();
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
// otherwise we just scroll to preserve the selection.
|
|
525
|
+
this._cm.editor.dispatch({
|
|
526
|
+
effects: EditorView.scrollIntoView(match.position)
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
this._current = null;
|
|
533
|
+
}
|
|
534
|
+
this._refresh();
|
|
535
|
+
}
|
|
536
|
+
_refresh() {
|
|
537
|
+
if (!this._cm) {
|
|
538
|
+
// no-op
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
let effects = [
|
|
542
|
+
this._highlightEffect.of({
|
|
543
|
+
matches: this.matches,
|
|
544
|
+
currentMatch: this._current
|
|
545
|
+
})
|
|
546
|
+
];
|
|
547
|
+
if (!this._cm.state.field(this._highlightField, false)) {
|
|
548
|
+
effects.push(StateEffect.appendConfig.of([this._highlightField]));
|
|
549
|
+
// set cursor on active match when editor gets focused
|
|
550
|
+
const focusExtension = EditorView.domEventHandlers({
|
|
551
|
+
focus: () => {
|
|
552
|
+
this._selectCurrentMatch();
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
effects.push(StateEffect.appendConfig.of([focusExtension]));
|
|
556
|
+
}
|
|
557
|
+
this._cm.editor.dispatch({ effects });
|
|
558
|
+
}
|
|
559
|
+
_findNext(reverse, fromCursor = false) {
|
|
560
|
+
if (this._matches.length === 0) {
|
|
561
|
+
// No-op
|
|
562
|
+
return null;
|
|
563
|
+
}
|
|
564
|
+
let lastPosition = 0;
|
|
565
|
+
if (this._cm.hasFocus() || fromCursor) {
|
|
566
|
+
const cursor = this._cm.state.selection.main;
|
|
567
|
+
lastPosition = reverse ? cursor.anchor : cursor.head;
|
|
568
|
+
}
|
|
569
|
+
else if (this._current) {
|
|
570
|
+
lastPosition = reverse
|
|
571
|
+
? this._current.position
|
|
572
|
+
: this._current.position + this._current.text.length;
|
|
573
|
+
}
|
|
574
|
+
if (lastPosition === 0 && reverse && this.currentIndex === null) {
|
|
575
|
+
// The default position is (0, 0) but we want to start from the end in that case
|
|
576
|
+
lastPosition = this._cm.doc.length;
|
|
577
|
+
}
|
|
578
|
+
const position = lastPosition;
|
|
579
|
+
let found = Utils.findNext(this._matches, position, 0, this._matches.length - 1);
|
|
580
|
+
if (found === null) {
|
|
581
|
+
// Don't loop
|
|
582
|
+
return reverse ? this._matches.length - 1 : null;
|
|
583
|
+
}
|
|
584
|
+
if (reverse) {
|
|
585
|
+
found -= 1;
|
|
586
|
+
if (found < 0) {
|
|
587
|
+
// Don't loop
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return found;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Helpers namespace
|
|
596
|
+
*/
|
|
597
|
+
var Utils;
|
|
598
|
+
(function (Utils) {
|
|
599
|
+
/**
|
|
600
|
+
* Find the closest match at `position` just after it.
|
|
601
|
+
*
|
|
602
|
+
* #### Notes
|
|
603
|
+
* Search is done using a binary search algorithm
|
|
604
|
+
*
|
|
605
|
+
* @param matches List of matches
|
|
606
|
+
* @param position Searched position
|
|
607
|
+
* @param lowerBound Lower range index
|
|
608
|
+
* @param higherBound High range index
|
|
609
|
+
* @returns The next match or null if none exists
|
|
610
|
+
*/
|
|
611
|
+
function findNext(matches, position, lowerBound = 0, higherBound = Infinity) {
|
|
612
|
+
higherBound = Math.min(matches.length - 1, higherBound);
|
|
613
|
+
while (lowerBound <= higherBound) {
|
|
614
|
+
let middle = Math.floor(0.5 * (lowerBound + higherBound));
|
|
615
|
+
const currentPosition = matches[middle].position;
|
|
616
|
+
if (currentPosition < position) {
|
|
617
|
+
lowerBound = middle + 1;
|
|
618
|
+
if (lowerBound < matches.length &&
|
|
619
|
+
matches[lowerBound].position > position) {
|
|
620
|
+
return lowerBound;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
else if (currentPosition > position) {
|
|
624
|
+
higherBound = middle - 1;
|
|
625
|
+
if (higherBound > 0 && matches[higherBound].position < position) {
|
|
626
|
+
return middle;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
return middle;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
// Next could be the first item
|
|
634
|
+
const first = lowerBound > 0 ? lowerBound - 1 : 0;
|
|
635
|
+
const match = matches[first];
|
|
636
|
+
return match.position >= position ? first : null;
|
|
637
|
+
}
|
|
638
|
+
Utils.findNext = findNext;
|
|
639
|
+
})(Utils || (Utils = {}));
|
|
640
|
+
//# sourceMappingURL=searchprovider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchprovider.js","sourceRoot":"","sources":["../src/searchprovider.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAiC3D,OAAO,EAAE,WAAW,EAAmB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAiB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EACL,qBAAqB,EAIrB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAW,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;GAEG;AACH,MAAM,OAAgB,oBAAoB;IAIxC;;OAEG;IACH;QAyWA;;WAEG;QACO,iBAAY,GAAkB,IAAI,CAAC;QAK7C;;WAEG;QACO,UAAK,GAAkB,IAAI,CAAC;QAG9B,cAAS,GAAG,IAAI,CAAC;QACjB,iBAAY,GAA6B,IAAI,CAAC;QAC9C,gBAAW,GAAG,KAAK,CAAC;QACpB,eAAU,GAAuC,IAAI,CAAC;QAzX5D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI,MAAM,CAA4B,IAAI,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,IAAc,SAAS;QACrB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,CAAC,UAAU,GAAG,IAAI,2BAA2B,CAC/C,IAAI,CAAC,MAA0B,CAChC,CAAC;SACH;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAWD;;OAEG;IACH,IAAI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