Sha256: 02eb642fe30783246510ec2b3cc1edc5a2a14f414aea11cc52c68a8c3cc1bb56

Contents?: true

Size: 1.64 KB

Versions: 81

Compression:

Stored size: 1.64 KB

Contents

// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

(function(mod) {
  if (typeof exports == "object" && typeof module == "object") // CommonJS
    mod(require("../../lib/codemirror"));
  else if (typeof define == "function" && define.amd) // AMD
    define(["../../lib/codemirror"], mod);
  else // Plain browser env
    mod(CodeMirror);
})(function(CodeMirror) {
  "use strict";

  var WORD = /[\w$]+/, RANGE = 500;

  CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
    var word = options && options.word || WORD;
    var range = options && options.range || RANGE;
    var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
    var end = cur.ch, start = end;
    while (start && word.test(curLine.charAt(start - 1))) --start;
    var curWord = start != end && curLine.slice(start, end);

    var list = options && options.list || [], seen = {};
    var re = new RegExp(word.source, "g");
    for (var dir = -1; dir <= 1; dir += 2) {
      var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
      for (; line != endLine; line += dir) {
        var text = editor.getLine(line), m;
        while (m = re.exec(text)) {
          if (line == cur.line && m[0] === curWord) continue;
          if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) {
            seen[m[0]] = true;
            list.push(m[0]);
          }
        }
      }
    }
    return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
  });
});

Version data entries

81 entries across 55 versions & 8 rubygems

Version Path
keppler-2.1.5 installer/core/app/assets/javascripts/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.5 installer/core/app/assets/stylesheets/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.4 installer/core/app/assets/stylesheets/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.4 installer/core/app/assets/javascripts/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.3 installer/core/app/assets/javascripts/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.3 installer/core/app/assets/stylesheets/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.2 installer/core/app/assets/stylesheets/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.2 installer/core/app/assets/javascripts/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.1 installer/core/app/assets/javascripts/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.1 installer/core/app/assets/stylesheets/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.pre.p1 installer/core/app/assets/stylesheets/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1.pre.p1 installer/core/app/assets/javascripts/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1 installer/core/app/assets/javascripts/admin/codemirror/addon/hint/anyword-hint.js
keppler-2.1 installer/core/app/assets/stylesheets/admin/codemirror/addon/hint/anyword-hint.js
tui_editor-rails-1.0.2.0 vendor/assets/components/codemirror/addon/hint/anyword-hint.js
glebtv-ckeditor-4.6.0 vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/anyword-hint.js
codemirror-rails-5.16.0 vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js
codemirror-rails-5.15.2 vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js
codemirror-rails-5.13.2 vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js
codemirror-rails-5.12 vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js