Socket
Socket
Sign inDemoInstall

nuclide-commons-atom

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuclide-commons-atom - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

test-helpers.js

5

package.json
{
"name": "nuclide-commons-atom",
"version": "0.1.9",
"version": "0.1.10",
"description": "Common Nuclide node modules (for use with Atom only).",

@@ -15,4 +15,5 @@ "license": "BSD-3-Clause",

"async-to-generator": "1.1.0",
"escape-string-regexp": "1.0.5",
"log4js": "1.1.1",
"nuclide-commons": "0.1.9",
"nuclide-commons": "0.1.10",
"rxjs": "5.3.1",

@@ -19,0 +20,0 @@ "semver": "5.3.0",

34

range.js

@@ -18,2 +18,8 @@ 'use strict';

/**
* Finds the word at the position. You can either provide a word regex yourself,
* or have Atom use the word regex in force at the scopes at that position,
* in which case it uses the optional includeNonWordCharacters, default true.
* (I know that's a weird default but it follows Atom's convention...)
*/
/**
* Copyright (c) 2017-present, Facebook, Inc.

@@ -30,9 +36,25 @@ * All rights reserved.

function wordAtPosition(editor, position, wordRegex_) {
let wordRegex = wordRegex_;
if (!wordRegex) {
wordRegex = editor.getLastCursor().wordRegExp();
function wordAtPosition(editor, position, wordRegex) {
let wordRegex_;
if (wordRegex instanceof RegExp) {
wordRegex_ = wordRegex;
} else {
// What is the word regex associated with the position? We'd like to use
// atom$Cursor.wordRegExp, except that function gets the regex associated
// with the editor's current cursor while we want the regex associated with
// the specific position. So we re-implement it ourselves...
const scopeDescriptor = editor.scopeDescriptorForBufferPosition(position);
const nonWordChars = editor.getNonWordCharacters(scopeDescriptor);
const escaped = nonWordChars.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
// We copied this escaping regex from atom$Cursor.wordRegexp, rather than
// using the library function 'escapeStringRegExp'. That's because the
// library function doesn't escape the hyphen character and so is
// unsuitable for use inside a range.
let r = `^[\t ]*$|[^\\s${escaped}]+`;
if (wordRegex == null || wordRegex.includeNonWordCharacters) {
r += `|[${escaped}]+`;
}
wordRegex_ = new RegExp(r, 'g');
}
const buffer = editor.getBuffer();
return (0, (_range || _load_range()).wordAtPositionFromBuffer)(buffer, position, wordRegex);
return (0, (_range || _load_range()).wordAtPositionFromBuffer)(editor.getBuffer(), position, wordRegex_);
}

@@ -39,0 +61,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc