You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for Unicode boundaries and detection methods
Introduced Unicode boundaries support in text search
Added supportsLookbehind and supportsUnicodeFlag methods in lang for feature detection
Implemented fallback to ASCII boundaries when the browser does not support look-behinds
Implemented fallback to old behaviour (without unicode support) in rare edge cases for backward compatibility
Copy file name to clipboardexpand all lines: src/search.js
+72-28
Original file line number
Diff line number
Diff line change
@@ -10,27 +10,34 @@ var Range = require("./range").Range;
10
10
classSearch{
11
11
/**
12
12
* Creates a new `Search` object. The following search options are available:
13
-
*
14
-
* - `needle`: The string or regular expression you're looking for
15
-
* - `backwards`: Whether to search backwards from where cursor currently is. Defaults to `false`.
16
-
* - `wrap`: Whether to wrap the search back to the beginning when it hits the end. Defaults to `false`.
17
-
* - `caseSensitive`: Whether the search ought to be case-sensitive. Defaults to `false`.
18
-
* - `wholeWord`: Whether the search matches only on whole words. Defaults to `false`.
19
-
* - `range`: The [[Range]] to search within. Set this to `null` for the whole document
20
-
* - `regExp`: Whether the search is a regular expression or not. Defaults to `false`.
21
-
* - `start`: The starting [[Range]] or cursor position to begin the search
22
-
* - `skipCurrent`: Whether or not to include the current line in the search. Default to `false`.
23
-
*
13
+
* @typedef SearchOptions
14
+
*
15
+
* @property {string|RegExp} [needle] - The string or regular expression you're looking for
16
+
* @property {boolean} [backwards] - Whether to search backwards from where cursor currently is
17
+
* @property {boolean} [wrap] - Whether to wrap the search back to the beginning when it hits the end
18
+
* @property {boolean} [caseSensitive] - Whether the search ought to be case-sensitive
19
+
* @property {boolean} [wholeWord] - Whether the search matches only on whole words
20
+
* @property {Range|null} [range] - The [[Range]] to search within. Set this to `null` for the whole document
21
+
* @property {boolean} [regExp] - Whether the search is a regular expression or not
22
+
* @property {Range|Position} [start] - The starting [[Range]] or cursor position to begin the search
23
+
* @property {boolean} [skipCurrent] - Whether or not to include the current line in the search
24
+
* @property {boolean} [$isMultiLine] - true, if needle has \n or \r\n
25
+
* @property {boolean} [preserveCase]
26
+
* @property {boolean} [preventScroll]
27
+
* @property {boolean} [$supportsUnicodeFlag] - internal property, determine if browser supports unicode flag
28
+
* @property {any} [re]
24
29
**/
30
+
25
31
constructor(){
32
+
/**
33
+
* @type {SearchOptions}
34
+
*/
26
35
this.$options={};
27
36
}
28
37
29
38
/**
30
39
* Sets the search options via the `options` parameter.
31
-
* @param {Object} options An object containing all the new search properties
32
-
*
33
-
*
40
+
* @param {SearchOptions} options An object containing all the new search properties
34
41
* @returns {Search}
35
42
* @chainable
36
43
**/
@@ -41,27 +48,26 @@ class Search {
41
48
42
49
/**
43
50
* [Returns an object containing all the search options.]{: #Search.getOptions}
44
-
* @returns {Object}
51
+
* @returns {SearchOptions}
45
52
**/
46
53
getOptions(){
47
54
returnlang.copyObject(this.$options);
48
55
}
49
56
50
57
/**
51
58
* Sets the search options via the `options` parameter.
52
-
* @param {Object} options object containing all the search propertie
59
+
* @param {SearchOptions} options object containing all the search propertie
53
60
* @related Search.set
54
61
**/
55
62
setOptions(options){
56
63
this.$options=options;
57
64
}
65
+
58
66
/**
59
67
* Searches for `options.needle`. If found, this method returns the [[Range `Range`]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
60
68
* @param {EditSession} session The session to search with
61
-
*
62
-
*
63
-
* @returns {Range}
64
-
**/
69
+
* @returns {Range|boolean}
70
+
**/
65
71
find(session){
66
72
varoptions=this.$options;
67
73
variterator=this.$matchIterator(session,options);
@@ -87,9 +93,7 @@ class Search {
87
93
/**
88
94
* Searches for all occurrances `options.needle`. If found, this method returns an array of [[Range `Range`s]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
89
95
* @param {EditSession} session The session to search with
0 commit comments