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
Copy file name to clipboardExpand all lines: lib/misc/words.js
+58-20Lines changed: 58 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -21,47 +21,85 @@ export function withWord (editor, fn) {
21
21
*
22
22
* `options`
23
23
* - `bufferPosition` {Point}: If given returns the word at the `bufferPosition`, returns the word at the current cursor otherwise.
24
-
* - `wordRegex` {RegExp} : A RegExp indicating what constitutes a “word” (default: `wordRegex`).
24
+
* - `wordRegex` {RegExp} : A RegExp indicating what constitutes a “word”. Will be used if not both `beginWordRegex and `endWordRegex` are passed. (default: `wordRegex`).
25
+
* - `beginWordRegex` {RegExp} : A RegExp to find a beginning of a “word”. Should be passed with `endWordRegex`. (default: `undefined`).
26
+
* - `endWordRegex` {RegExp} : A RegExp to find an end of a “word”. Should be passed with `beginWordRegex`. (default: `undefined`).
25
27
*/
26
28
exportfunctiongetWordAndRange(editor,options={
27
29
bufferPosition: undefined,
28
-
wordRegex: wordRegex
30
+
wordRegex: wordRegex,
31
+
beginWordRegex: undefined,
32
+
endWordRegex: undefined
29
33
}){
30
34
// @TODO?:
31
35
// The following lines are kinda iffy: The regex may or may not be well chosen
32
36
// and it duplicates the efforts from atom-language-julia.
33
37
// It might be better to select the current word via finding the smallest <span>
34
38
// containing the bufferPosition/cursor which also has `function` or `macro` as its class.
* adapted from https://github.com/atom/atom/blob/v1.38.2/src/cursor.js#L606-L616
49
48
*
50
49
* `options`
51
-
* - `wordRegex` {RegExp}: A RegExp indicating what constitutes a “word” (default: `wordRegex`).
50
+
* - `wordRegex` {RegExp}: A RegExp indicating what constitutes a “word”. Will be used if not both `beginWordRegex and `endWordRegex` are passed. (default: `wordRegex`).
51
+
* - `beginWordRegex` {RegExp} : A RegExp to find a beginning of a “word”. Should be passed with `endWordRegex`. (default: `undefined`).
52
+
* - `endWordRegex` {RegExp} : A RegExp to find an end of a “word”. Should be passed with `beginWordRegex`. (default: `undefined`).
0 commit comments