-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{Range} = require 'atom' | ||
|
||
LanguageClientUtils = require '../node_modules/atom-languageclient/build/lib/utils' | ||
|
||
module.exports = | ||
###* | ||
* Slightly modified variant of the LanguageClientUtils getWordAtPosition. | ||
* | ||
* This variant does not treat the backslash as a non-word character, so it is not treated as boundary and the range | ||
* does not stop when it is found. This is important for qualified names in PHP (i.e. imports, qualified function | ||
* calls, ...). | ||
* | ||
* @param {TextEditor} editor | ||
* @param {Point} position | ||
* | ||
* @see https://github.com/atom/atom-languageclient/blob/master/lib/utils.js | ||
### | ||
getRangeForSymbolAtPosition: (editor, position) -> | ||
scopeDescriptor = editor.scopeDescriptorForBufferPosition(position) | ||
nonWordCharacters = editor.getNonWordCharacters(scopeDescriptor) | ||
nonWordCharacters = nonWordCharacters.replace("\\", '') | ||
nonWordCharacters = LanguageClientUtils.escapeRegExp(nonWordCharacters) | ||
|
||
range = LanguageClientUtils._getRegexpRangeAtPosition( | ||
editor.getBuffer(), | ||
position, | ||
///^[\t ]*$|[^\s#{nonWordCharacters}]+///g | ||
) | ||
|
||
if range == null | ||
return new Range(position, position); | ||
|
||
return range |