1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-30 09:13:16 +00:00
TiddlyWiki5/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/anyword-hint.js
Simon Huber 769ffa19b7
Update CodeMirror plugins to v5.58.2 (#4950)
* Update codemirror.js to 5.58.2

* Update codemirror.css to 5.58.2

* Update activeline.js to 5.58.2

* Update dialog.js to 5.58.2

* Update jump-to-line.js to 5.58.2

* Update search.js to 5.58.2

* Update searchcursor.js to 5.58.2

* Update xml.js to 5.58.2

* Update show-hint.js to 5.58.2

* Update show-hint.css to 5.58.2

* Update javascript-hint.js to 5.58.2

* Update xml-hint.js to 5.58.2

* Update html-hint.js to 5.58.2

* Update css-hint.js to 5.58.2

* Update anyword-hint.js to 5.58.2

* Update closebrackets.js to 5.58.2

* Update matchbrackets.js to 5.58.2

* Update closetag.js to 5.58.2

* Update xml-fold.js to 5.58.2

* Update fullscreen.js to 5.58.2

* Update emacs.js to 5.58.2

* Update sublime.js to 5.58.2

* Update comment.js to 5.58.2

* Update vim.js to 5.58.2

* Update css.js to 5.58.2

* Update multiplex.js to 5.58.2

* Update htmlembedded.js to 5.58.2

* Update htmlmixed.js to 5.58.2

* Update javascript.js to 5.58.2

* Update markdown.js to 5.58.2

* Update markdown.js

* Update readme.tid

* Update markdown.js
2020-11-01 11:10:00 +00:00

4 lines
916 B
JavaScript

// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(y){"use strict";var b=/[\w$]+/;y.registerHelper("hint","anyword",function(e,r){for(var t=r&&r.word||b,o=r&&r.range||500,i=e.getCursor(),n=e.getLine(i.line),f=i.ch,s=f;s&&t.test(n.charAt(s-1));)--s;for(var a=s!=f&&n.slice(s,f),c=r&&r.list||[],l={},d=new RegExp(t.source,"g"),u=-1;u<=1;u+=2)for(var p=i.line,g=Math.min(Math.max(p+u*o,e.firstLine()),e.lastLine())+u;p!=g;p+=u)for(var h,m=e.getLine(p);h=d.exec(m);)p==i.line&&h[0]===a||a&&0!=h[0].lastIndexOf(a,0)||Object.prototype.hasOwnProperty.call(l,h[0])||(l[h[0]]=!0,c.push(h[0]));return{list:c,from:y.Pos(i.line,s),to:y.Pos(i.line,f)}})});