How to use the oniguruma.OnigString function in oniguruma

To help you get started, we’ve selected a few oniguruma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atom / first-mate / src / grammar.js View on Github external
tokenizeLine (inputLine, ruleStack, firstLine = false, compatibilityMode = true) {
    let line, openScopeTags
    const tags = []

    let truncatedLine = false
    if (inputLine.length > this.maxLineLength) {
      line = inputLine.slice(0, this.maxLineLength)
      truncatedLine = true
    } else {
      line = inputLine
    }

    const string = new OnigString(`${line}\n`)

    if (ruleStack) {
      ruleStack = ruleStack.slice()
      if (compatibilityMode) {
        openScopeTags = []
        for (let {scopeName, contentScopeName} of ruleStack) {
          if (scopeName) { openScopeTags.push(this.registry.startIdForScope(scopeName)) }
          if (contentScopeName) { openScopeTags.push(this.registry.startIdForScope(contentScopeName)) }
        }
      }
    } else {
      if (compatibilityMode) { openScopeTags = [] }
      const initialRule = this.getInitialRule()
      let {scopeName, contentScopeName} = initialRule
      ruleStack = [{rule: initialRule, scopeName, contentScopeName}]
      if (scopeName) { tags.push(this.startIdForScope(initialRule.scopeName)) }