ace-rails-ap 4.2 → 4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ace/rails/version.rb +1 -1
- data/update.sh +1 -1
- data/vendor/assets/javascripts/ace/ace.js +661 -160
- data/vendor/assets/javascripts/ace/ext-beautify.js +1 -0
- data/vendor/assets/javascripts/ace/ext-emmet.js +314 -218
- data/vendor/assets/javascripts/ace/ext-keybinding_menu.js +37 -32
- data/vendor/assets/javascripts/ace/ext-language_tools.js +362 -225
- data/vendor/assets/javascripts/ace/ext-linking.js +1 -1
- data/vendor/assets/javascripts/ace/ext-modelist.js +6 -2
- data/vendor/assets/javascripts/ace/ext-options.js +45 -34
- data/vendor/assets/javascripts/ace/ext-prompt.js +2764 -0
- data/vendor/assets/javascripts/ace/ext-rtl.js +1 -3
- data/vendor/assets/javascripts/ace/ext-settings_menu.js +49 -38
- data/vendor/assets/javascripts/ace/ext-statusbar.js +2 -2
- data/vendor/assets/javascripts/ace/ext-whitespace.js +4 -0
- data/vendor/assets/javascripts/ace/keybinding-emacs.js +1 -0
- data/vendor/assets/javascripts/ace/keybinding-vim.js +296 -66
- data/vendor/assets/javascripts/ace/mode-aql.js +102 -0
- data/vendor/assets/javascripts/ace/mode-autohotkey.js +3 -1
- data/vendor/assets/javascripts/ace/mode-cirru.js +2 -2
- data/vendor/assets/javascripts/ace/mode-crystal.js +642 -0
- data/vendor/assets/javascripts/ace/mode-csound_document.js +42 -29
- data/vendor/assets/javascripts/ace/mode-csound_orchestra.js +35 -25
- data/vendor/assets/javascripts/ace/mode-csound_score.js +29 -21
- data/vendor/assets/javascripts/ace/mode-fsharp.js +2 -2
- data/vendor/assets/javascripts/ace/mode-gherkin.js +0 -2
- data/vendor/assets/javascripts/ace/mode-gobstones.js +252 -94
- data/vendor/assets/javascripts/ace/mode-io.js +1 -7
- data/vendor/assets/javascripts/ace/mode-jade.js +1 -1
- data/vendor/assets/javascripts/ace/mode-lua.js +30 -10
- data/vendor/assets/javascripts/ace/mode-luapage.js +30 -10
- data/vendor/assets/javascripts/ace/mode-lucene.js +77 -9
- data/vendor/assets/javascripts/ace/mode-markdown.js +2 -1
- data/vendor/assets/javascripts/ace/mode-mask.js +1 -1
- data/vendor/assets/javascripts/ace/mode-nginx.js +298 -0
- data/vendor/assets/javascripts/ace/mode-nim.js +363 -0
- data/vendor/assets/javascripts/ace/mode-pascal.js +84 -66
- data/vendor/assets/javascripts/ace/mode-php.js +1 -1
- data/vendor/assets/javascripts/ace/mode-php_laravel_blade.js +1 -1
- data/vendor/assets/javascripts/ace/mode-puppet.js +3 -3
- data/vendor/assets/javascripts/ace/mode-slim.js +2 -1
- data/vendor/assets/javascripts/ace/mode-tcl.js +3 -0
- data/vendor/assets/javascripts/ace/mode-terraform.js +4 -4
- data/vendor/assets/javascripts/ace/mode-yaml.js +44 -13
- data/vendor/assets/javascripts/ace/mode-zeek.js +539 -0
- data/vendor/assets/javascripts/ace/snippets/abap.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/abc.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/actionscript.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/ada.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/apache_conf.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/apex.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/applescript.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/aql.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/asciidoc.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/asl.js +13 -0
- data/vendor/assets/javascripts/ace/snippets/assembly_x86.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/autohotkey.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/batchfile.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/bro.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/c9search.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/c_cpp.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/cirru.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/clojure.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/cobol.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/coffee.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/coldfusion.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/crystal.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/csharp.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/csound_document.js +24 -0
- data/vendor/assets/javascripts/ace/snippets/csound_orchestra.js +61 -0
- data/vendor/assets/javascripts/ace/snippets/csound_score.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/csp.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/css.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/curly.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/d.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/dart.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/diff.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/django.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/dockerfile.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/dot.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/drools.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/edifact.js +254 -0
- data/vendor/assets/javascripts/ace/snippets/eiffel.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/ejs.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/elixir.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/elm.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/erlang.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/forth.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/fortran.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/fsharp.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/fsl.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/ftl.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/gcode.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/gherkin.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/gitignore.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/glsl.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/gobstones.js +1701 -24
- data/vendor/assets/javascripts/ace/snippets/golang.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/graphqlschema.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/groovy.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/haml.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/handlebars.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/haskell.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/haskell_cabal.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/haxe.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/hjson.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/html.js +36 -2
- data/vendor/assets/javascripts/ace/snippets/html_elixir.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/html_ruby.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/ini.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/io.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/jack.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/jade.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/java.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/javascript.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/json.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/jsoniq.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/jsp.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/jssm.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/jsx.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/julia.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/kotlin.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/latex.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/less.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/liquid.js +890 -2
- data/vendor/assets/javascripts/ace/snippets/lisp.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/livescript.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/logiql.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/logtalk.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/lsl.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/lua.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/luapage.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/lucene.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/makefile.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/markdown.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/mask.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/matlab.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/maze.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/mel.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/mixal.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/mushcode.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/mysql.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/nginx.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/nim.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/nix.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/nsis.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/objectivec.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/ocaml.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/pascal.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/perl.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/perl6.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/pgsql.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/php.js +49 -36
- data/vendor/assets/javascripts/ace/snippets/php_laravel_blade.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/pig.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/plain_text.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/powershell.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/praat.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/prolog.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/properties.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/protobuf.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/puppet.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/python.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/r.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/razor.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/rdoc.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/red.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/redshift.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/rhtml.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/rst.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/ruby.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/rust.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/sass.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/scad.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/scala.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/scheme.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/scss.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/sh.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/sjs.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/slim.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/smarty.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/snippets.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/soy_template.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/space.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/sparql.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/sql.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/sqlserver.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/stylus.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/svg.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/swift.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/tcl.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/terraform.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/tex.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/text.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/textile.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/toml.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/tsx.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/turtle.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/twig.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/typescript.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/vala.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/vbscript.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/velocity.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/verilog.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/vhdl.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/visualforce.js +14 -0
- data/vendor/assets/javascripts/ace/snippets/wollok.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/xml.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/xquery.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/yaml.js +8 -1
- data/vendor/assets/javascripts/ace/snippets/zeek.js +14 -0
- data/vendor/assets/javascripts/ace/worker-coffee.js +2 -2
- data/vendor/assets/javascripts/ace/worker-css.js +9 -3
- data/vendor/assets/javascripts/ace/worker-html.js +2 -2
- data/vendor/assets/javascripts/ace/worker-javascript.js +2 -2
- data/vendor/assets/javascripts/ace/worker-json.js +2 -2
- data/vendor/assets/javascripts/ace/worker-lua.js +2 -2
- data/vendor/assets/javascripts/ace/worker-php.js +4 -4
- data/vendor/assets/javascripts/ace/worker-xml.js +2 -2
- data/vendor/assets/javascripts/ace/worker-xquery.js +2 -2
- metadata +34 -16
- data/vendor/assets/javascripts/ace/ext-chromevox.js +0 -540
- data/vendor/assets/javascripts/ace/ext-old_ie.js +0 -502
- data/vendor/assets/javascripts/ace/mode-bash.js +0 -247
- data/vendor/assets/javascripts/ace/mode-lean.js +0 -281
- data/vendor/assets/javascripts/ace/mode-live_script.js +0 -481
- data/vendor/assets/javascripts/ace/mode-mips_assembler.js +0 -235
- data/vendor/assets/javascripts/ace/mode-mipsassembler.js +0 -196
- data/vendor/assets/javascripts/ace/mode-swig.js +0 -1099
- data/vendor/assets/javascripts/ace/snippets/lean.js +0 -7
- data/vendor/assets/javascripts/ace/snippets/live_script.js +0 -7
- data/vendor/assets/javascripts/ace/snippets/mips_assembler.js +0 -7
- data/vendor/assets/javascripts/ace/snippets/mipsassembler.js +0 -7
- data/vendor/assets/javascripts/ace/snippets/swig.js +0 -7
@@ -1,13 +1,88 @@
|
|
1
|
-
define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/
|
1
|
+
define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/lib/dom","ace/editor"], function(require, exports, module) {
|
2
2
|
"use strict";
|
3
3
|
var oop = require("./lib/oop");
|
4
4
|
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
5
5
|
var lang = require("./lib/lang");
|
6
6
|
var Range = require("./range").Range;
|
7
|
-
var
|
7
|
+
var RangeList = require("./range_list").RangeList;
|
8
8
|
var HashHandler = require("./keyboard/hash_handler").HashHandler;
|
9
9
|
var Tokenizer = require("./tokenizer").Tokenizer;
|
10
|
-
var
|
10
|
+
var clipboard = require("./clipboard");
|
11
|
+
|
12
|
+
var VARIABLES = {
|
13
|
+
CURRENT_WORD: function(editor) {
|
14
|
+
return editor.session.getTextRange(editor.session.getWordRange());
|
15
|
+
},
|
16
|
+
SELECTION: function(editor, name, indentation) {
|
17
|
+
var text = editor.session.getTextRange();
|
18
|
+
if (indentation)
|
19
|
+
return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1");
|
20
|
+
return text;
|
21
|
+
},
|
22
|
+
CURRENT_LINE: function(editor) {
|
23
|
+
return editor.session.getLine(editor.getCursorPosition().row);
|
24
|
+
},
|
25
|
+
PREV_LINE: function(editor) {
|
26
|
+
return editor.session.getLine(editor.getCursorPosition().row - 1);
|
27
|
+
},
|
28
|
+
LINE_INDEX: function(editor) {
|
29
|
+
return editor.getCursorPosition().row;
|
30
|
+
},
|
31
|
+
LINE_NUMBER: function(editor) {
|
32
|
+
return editor.getCursorPosition().row + 1;
|
33
|
+
},
|
34
|
+
SOFT_TABS: function(editor) {
|
35
|
+
return editor.session.getUseSoftTabs() ? "YES" : "NO";
|
36
|
+
},
|
37
|
+
TAB_SIZE: function(editor) {
|
38
|
+
return editor.session.getTabSize();
|
39
|
+
},
|
40
|
+
CLIPBOARD: function(editor) {
|
41
|
+
return clipboard.getText && clipboard.getText();
|
42
|
+
},
|
43
|
+
FILENAME: function(editor) {
|
44
|
+
return /[^/\\]*$/.exec(this.FILEPATH(editor))[0];
|
45
|
+
},
|
46
|
+
FILENAME_BASE: function(editor) {
|
47
|
+
return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, "");
|
48
|
+
},
|
49
|
+
DIRECTORY: function(editor) {
|
50
|
+
return this.FILEPATH(editor).replace(/[^/\\]*$/, "");
|
51
|
+
},
|
52
|
+
FILEPATH: function(editor) { return "/not implemented.txt"; },
|
53
|
+
WORKSPACE_NAME: function() { return "Unknown"; },
|
54
|
+
FULLNAME: function() { return "Unknown"; },
|
55
|
+
BLOCK_COMMENT_START: function(editor) {
|
56
|
+
var mode = editor.session.$mode || {};
|
57
|
+
return mode.blockComment && mode.blockComment.start || "";
|
58
|
+
},
|
59
|
+
BLOCK_COMMENT_END: function(editor) {
|
60
|
+
var mode = editor.session.$mode || {};
|
61
|
+
return mode.blockComment && mode.blockComment.end || "";
|
62
|
+
},
|
63
|
+
LINE_COMMENT: function(editor) {
|
64
|
+
var mode = editor.session.$mode || {};
|
65
|
+
return mode.lineCommentStart || "";
|
66
|
+
},
|
67
|
+
CURRENT_YEAR: date.bind(null, {year: "numeric"}),
|
68
|
+
CURRENT_YEAR_SHORT: date.bind(null, {year: "2-digit"}),
|
69
|
+
CURRENT_MONTH: date.bind(null, {month: "numeric"}),
|
70
|
+
CURRENT_MONTH_NAME: date.bind(null, {month: "long"}),
|
71
|
+
CURRENT_MONTH_NAME_SHORT: date.bind(null, {month: "short"}),
|
72
|
+
CURRENT_DATE: date.bind(null, {day: "2-digit"}),
|
73
|
+
CURRENT_DAY_NAME: date.bind(null, {weekday: "long"}),
|
74
|
+
CURRENT_DAY_NAME_SHORT: date.bind(null, {weekday: "short"}),
|
75
|
+
CURRENT_HOUR: date.bind(null, {hour: "2-digit", hour12: false}),
|
76
|
+
CURRENT_MINUTE: date.bind(null, {minute: "2-digit"}),
|
77
|
+
CURRENT_SECOND: date.bind(null, {second: "2-digit"})
|
78
|
+
};
|
79
|
+
|
80
|
+
VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION;
|
81
|
+
|
82
|
+
function date(dateFormat) {
|
83
|
+
var str = new Date().toLocaleString("en-us", dateFormat);
|
84
|
+
return str.length == 1 ? "0" + str : str;
|
85
|
+
}
|
11
86
|
|
12
87
|
var SnippetManager = function() {
|
13
88
|
this.snippetMap = {};
|
@@ -18,41 +93,40 @@ var SnippetManager = function() {
|
|
18
93
|
oop.implement(this, EventEmitter);
|
19
94
|
|
20
95
|
this.getTokenizer = function() {
|
21
|
-
|
96
|
+
return SnippetManager.$tokenizer || this.createTokenizer();
|
97
|
+
};
|
98
|
+
|
99
|
+
this.createTokenizer = function() {
|
100
|
+
function TabstopToken(str) {
|
22
101
|
str = str.substr(1);
|
23
|
-
if (/^\d+$/.test(str)
|
102
|
+
if (/^\d+$/.test(str))
|
24
103
|
return [{tabstopId: parseInt(str, 10)}];
|
25
104
|
return [{text: str}];
|
26
105
|
}
|
27
106
|
function escape(ch) {
|
28
107
|
return "(?:[^\\\\" + ch + "]|\\\\.)";
|
29
108
|
}
|
109
|
+
var formatMatcher = {
|
110
|
+
regex: "/(" + escape("/") + "+)/",
|
111
|
+
onMatch: function(val, state, stack) {
|
112
|
+
var ts = stack[0];
|
113
|
+
ts.fmtString = true;
|
114
|
+
ts.guard = val.slice(1, -1);
|
115
|
+
ts.flag = "";
|
116
|
+
return "";
|
117
|
+
},
|
118
|
+
next: "formatString"
|
119
|
+
};
|
120
|
+
|
30
121
|
SnippetManager.$tokenizer = new Tokenizer({
|
31
122
|
start: [
|
32
|
-
{regex: /:/, onMatch: function(val, state, stack) {
|
33
|
-
if (stack.length && stack[0].expectIf) {
|
34
|
-
stack[0].expectIf = false;
|
35
|
-
stack[0].elseBranch = stack[0];
|
36
|
-
return [stack[0]];
|
37
|
-
}
|
38
|
-
return ":";
|
39
|
-
}},
|
40
123
|
{regex: /\\./, onMatch: function(val, state, stack) {
|
41
124
|
var ch = val[1];
|
42
125
|
if (ch == "}" && stack.length) {
|
43
126
|
val = ch;
|
44
|
-
}else if ("`$\\".indexOf(ch) != -1) {
|
127
|
+
} else if ("`$\\".indexOf(ch) != -1) {
|
45
128
|
val = ch;
|
46
|
-
} else if (stack.inFormatString) {
|
47
|
-
if (ch == "n")
|
48
|
-
val = "\n";
|
49
|
-
else if (ch == "t")
|
50
|
-
val = "\n";
|
51
|
-
else if ("ulULE".indexOf(ch) != -1) {
|
52
|
-
val = {changeCase: ch, local: ch > "a"};
|
53
|
-
}
|
54
129
|
}
|
55
|
-
|
56
130
|
return [val];
|
57
131
|
}},
|
58
132
|
{regex: /}/, onMatch: function(val, state, stack) {
|
@@ -60,7 +134,7 @@ var SnippetManager = function() {
|
|
60
134
|
}},
|
61
135
|
{regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken},
|
62
136
|
{regex: /\$\{[\dA-Z_a-z]+/, onMatch: function(str, state, stack) {
|
63
|
-
var t = TabstopToken(str.substr(1)
|
137
|
+
var t = TabstopToken(str.substr(1));
|
64
138
|
stack.unshift(t[0]);
|
65
139
|
return t;
|
66
140
|
}, next: "snippetVar"},
|
@@ -68,39 +142,76 @@ var SnippetManager = function() {
|
|
68
142
|
],
|
69
143
|
snippetVar: [
|
70
144
|
{regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
ts.fmtString = val;
|
77
|
-
|
78
|
-
val = this.splitRegex.exec(val);
|
79
|
-
ts.guard = val[1];
|
80
|
-
ts.fmt = val[2];
|
81
|
-
ts.flag = val[3];
|
82
|
-
return "";
|
83
|
-
}, next: "start"},
|
84
|
-
{regex: "`" + escape("`") + "*`", onMatch: function(val, state, stack) {
|
85
|
-
stack[0].code = val.splice(1, -1);
|
86
|
-
return "";
|
87
|
-
}, next: "start"},
|
88
|
-
{regex: "\\?", onMatch: function(val, state, stack) {
|
89
|
-
if (stack[0])
|
90
|
-
stack[0].expectIf = true;
|
145
|
+
var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function(operator) {
|
146
|
+
return operator.length == 2 ? operator[1] : "\x00";
|
147
|
+
}).split("\x00");
|
148
|
+
stack[0].choices = choices;
|
149
|
+
return [choices[0]];
|
91
150
|
}, next: "start"},
|
151
|
+
formatMatcher,
|
92
152
|
{regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start"}
|
93
153
|
],
|
94
154
|
formatString: [
|
95
|
-
{regex:
|
96
|
-
|
97
|
-
|
155
|
+
{regex: /:/, onMatch: function(val, state, stack) {
|
156
|
+
if (stack.length && stack[0].expectElse) {
|
157
|
+
stack[0].expectElse = false;
|
158
|
+
stack[0].ifEnd = {elseEnd: stack[0]};
|
159
|
+
return [stack[0].ifEnd];
|
160
|
+
}
|
161
|
+
return ":";
|
162
|
+
}},
|
163
|
+
{regex: /\\./, onMatch: function(val, state, stack) {
|
164
|
+
var ch = val[1];
|
165
|
+
if (ch == "}" && stack.length)
|
166
|
+
val = ch;
|
167
|
+
else if ("`$\\".indexOf(ch) != -1)
|
168
|
+
val = ch;
|
169
|
+
else if (ch == "n")
|
170
|
+
val = "\n";
|
171
|
+
else if (ch == "t")
|
172
|
+
val = "\t";
|
173
|
+
else if ("ulULE".indexOf(ch) != -1)
|
174
|
+
val = {changeCase: ch, local: ch > "a"};
|
175
|
+
return [val];
|
176
|
+
}},
|
177
|
+
{regex: "/\\w*}", onMatch: function(val, state, stack) {
|
178
|
+
var next = stack.shift();
|
179
|
+
if (next)
|
180
|
+
next.flag = val.slice(1, -1);
|
181
|
+
this.next = next && next.tabstopId ? "start" : "";
|
182
|
+
return [next || val];
|
183
|
+
}, next: "start"},
|
184
|
+
{regex: /\$(?:\d+|\w+)/, onMatch: function(val, state, stack) {
|
185
|
+
return [{text: val.slice(1)}];
|
186
|
+
}},
|
187
|
+
{regex: /\${\w+/, onMatch: function(val, state, stack) {
|
188
|
+
var token = {text: val.slice(2)};
|
189
|
+
stack.unshift(token);
|
190
|
+
return [token];
|
191
|
+
}, next: "formatStringVar"},
|
192
|
+
{regex: /\n/, token: "newline", merge: false},
|
193
|
+
{regex: /}/, onMatch: function(val, state, stack) {
|
194
|
+
var next = stack.shift();
|
195
|
+
this.next = next && next.tabstopId ? "start" : "";
|
196
|
+
return [next || val];
|
98
197
|
}, next: "start"}
|
198
|
+
],
|
199
|
+
formatStringVar: [
|
200
|
+
{regex: /:\/\w+}/, onMatch: function(val, state, stack) {
|
201
|
+
var ts = stack[0];
|
202
|
+
ts.formatFunction = val.slice(2, -1);
|
203
|
+
return [stack.shift()];
|
204
|
+
}, next: "formatString"},
|
205
|
+
formatMatcher,
|
206
|
+
{regex: /:[\?\-+]?/, onMatch: function(val, state, stack) {
|
207
|
+
if (val[1] == "+")
|
208
|
+
stack[0].ifEnd = stack[0];
|
209
|
+
if (val[1] == "?")
|
210
|
+
stack[0].expectElse = true;
|
211
|
+
}, next: "formatString"},
|
212
|
+
{regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString"}
|
99
213
|
]
|
100
214
|
});
|
101
|
-
SnippetManager.prototype.getTokenizer = function() {
|
102
|
-
return SnippetManager.$tokenizer;
|
103
|
-
};
|
104
215
|
return SnippetManager.$tokenizer;
|
105
216
|
};
|
106
217
|
|
@@ -109,59 +220,33 @@ var SnippetManager = function() {
|
|
109
220
|
return x.value || x;
|
110
221
|
});
|
111
222
|
};
|
112
|
-
|
113
|
-
this
|
114
|
-
if (
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
return (this.variables.__ || {})[name];
|
120
|
-
}
|
223
|
+
|
224
|
+
this.getVariableValue = function(editor, name, indentation) {
|
225
|
+
if (/^\d+$/.test(name))
|
226
|
+
return (this.variables.__ || {})[name] || "";
|
227
|
+
if (/^[A-Z]\d+$/.test(name))
|
228
|
+
return (this.variables[name[0] + "__"] || {})[name.substr(1)] || "";
|
229
|
+
|
121
230
|
name = name.replace(/^TM_/, "");
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
var r = s.getWordRange();
|
129
|
-
case "SELECTION":
|
130
|
-
case "SELECTED_TEXT":
|
131
|
-
return s.getTextRange(r);
|
132
|
-
case "CURRENT_LINE":
|
133
|
-
return s.getLine(editor.getCursorPosition().row);
|
134
|
-
case "PREV_LINE": // not possible in textmate
|
135
|
-
return s.getLine(editor.getCursorPosition().row - 1);
|
136
|
-
case "LINE_INDEX":
|
137
|
-
return editor.getCursorPosition().column;
|
138
|
-
case "LINE_NUMBER":
|
139
|
-
return editor.getCursorPosition().row + 1;
|
140
|
-
case "SOFT_TABS":
|
141
|
-
return s.getUseSoftTabs() ? "YES" : "NO";
|
142
|
-
case "TAB_SIZE":
|
143
|
-
return s.getTabSize();
|
144
|
-
case "FILENAME":
|
145
|
-
case "FILEPATH":
|
146
|
-
return "";
|
147
|
-
case "FULLNAME":
|
148
|
-
return "Ace";
|
149
|
-
}
|
150
|
-
};
|
151
|
-
this.variables = {};
|
152
|
-
this.getVariableValue = function(editor, varName) {
|
153
|
-
if (this.variables.hasOwnProperty(varName))
|
154
|
-
return this.variables[varName](editor, varName) || "";
|
155
|
-
return this.$getDefaultValue(editor, varName) || "";
|
231
|
+
if (!this.variables.hasOwnProperty(name))
|
232
|
+
return "";
|
233
|
+
var value = this.variables[name];
|
234
|
+
if (typeof value == "function")
|
235
|
+
value = this.variables[name](editor, name, indentation);
|
236
|
+
return value == null ? "" : value;
|
156
237
|
};
|
238
|
+
|
239
|
+
this.variables = VARIABLES;
|
157
240
|
this.tmStrFormat = function(str, ch, editor) {
|
241
|
+
if (!ch.fmt) return str;
|
158
242
|
var flag = ch.flag || "";
|
159
243
|
var re = ch.guard;
|
160
|
-
re = new RegExp(re, flag.replace(/[^
|
161
|
-
var fmtTokens = this.tokenizeTmSnippet(ch.fmt, "formatString");
|
244
|
+
re = new RegExp(re, flag.replace(/[^gim]/g, ""));
|
245
|
+
var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt;
|
162
246
|
var _self = this;
|
163
247
|
var formatted = str.replace(re, function() {
|
164
|
-
_self.variables.__
|
248
|
+
var oldArgs = _self.variables.__;
|
249
|
+
_self.variables.__ = [].slice.call(arguments);
|
165
250
|
var fmtParts = _self.resolveVariables(fmtTokens, editor);
|
166
251
|
var gChangeCase = "E";
|
167
252
|
for (var i = 0; i < fmtParts.length; i++) {
|
@@ -186,40 +271,63 @@ var SnippetManager = function() {
|
|
186
271
|
fmtParts[i] = ch.toLowerCase();
|
187
272
|
}
|
188
273
|
}
|
274
|
+
_self.variables.__ = oldArgs;
|
189
275
|
return fmtParts.join("");
|
190
276
|
});
|
191
|
-
this.variables.__ = null;
|
192
277
|
return formatted;
|
193
278
|
};
|
279
|
+
|
280
|
+
this.tmFormatFunction = function(str, ch, editor) {
|
281
|
+
if (ch.formatFunction == "upcase")
|
282
|
+
return str.toUpperCase();
|
283
|
+
if (ch.formatFunction == "downcase")
|
284
|
+
return str.toLowerCase();
|
285
|
+
return str;
|
286
|
+
};
|
194
287
|
|
195
288
|
this.resolveVariables = function(snippet, editor) {
|
196
289
|
var result = [];
|
290
|
+
var indentation = "";
|
291
|
+
var afterNewLine = true;
|
197
292
|
for (var i = 0; i < snippet.length; i++) {
|
198
293
|
var ch = snippet[i];
|
199
294
|
if (typeof ch == "string") {
|
200
295
|
result.push(ch);
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
296
|
+
if (ch == "\n") {
|
297
|
+
afterNewLine = true;
|
298
|
+
indentation = "";
|
299
|
+
}
|
300
|
+
else if (afterNewLine) {
|
301
|
+
indentation = /^\t*/.exec(ch)[0];
|
302
|
+
afterNewLine = /\S/.test(ch);
|
303
|
+
}
|
206
304
|
continue;
|
207
|
-
}
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
305
|
+
}
|
306
|
+
if (!ch) continue;
|
307
|
+
afterNewLine = false;
|
308
|
+
|
309
|
+
if (ch.fmtString) {
|
310
|
+
var j = snippet.indexOf(ch, i + 1);
|
311
|
+
if (j == -1) j = snippet.length;
|
312
|
+
ch.fmt = snippet.slice(i + 1, j);
|
313
|
+
i = j;
|
314
|
+
}
|
315
|
+
|
316
|
+
if (ch.text) {
|
317
|
+
var value = this.getVariableValue(editor, ch.text, indentation) + "";
|
318
|
+
if (ch.fmtString)
|
319
|
+
value = this.tmStrFormat(value, ch, editor);
|
320
|
+
if (ch.formatFunction)
|
321
|
+
value = this.tmFormatFunction(value, ch, editor);
|
322
|
+
|
323
|
+
if (value && !ch.ifEnd) {
|
324
|
+
result.push(value);
|
325
|
+
gotoNext(ch);
|
326
|
+
} else if (!value && ch.ifEnd) {
|
327
|
+
gotoNext(ch.ifEnd);
|
222
328
|
}
|
329
|
+
} else if (ch.elseEnd) {
|
330
|
+
gotoNext(ch.elseEnd);
|
223
331
|
} else if (ch.tabstopId != null) {
|
224
332
|
result.push(ch);
|
225
333
|
} else if (ch.changeCase != null) {
|
@@ -263,9 +371,12 @@ var SnippetManager = function() {
|
|
263
371
|
ts = tabstops[id] = [];
|
264
372
|
ts.index = id;
|
265
373
|
ts.value = "";
|
374
|
+
ts.parents = {};
|
266
375
|
}
|
267
376
|
if (ts.indexOf(p) !== -1)
|
268
377
|
return;
|
378
|
+
if (p.choices && !ts.choices)
|
379
|
+
ts.choices = p.choices;
|
269
380
|
ts.push(p);
|
270
381
|
var i1 = tokens.indexOf(p, i + 1);
|
271
382
|
if (i1 === -1)
|
@@ -300,19 +411,24 @@ var SnippetManager = function() {
|
|
300
411
|
if (typeof p != "object")
|
301
412
|
continue;
|
302
413
|
var id = p.tabstopId;
|
414
|
+
var ts = tabstops[id];
|
303
415
|
var i1 = tokens.indexOf(p, i + 1);
|
304
416
|
if (expanding[id]) {
|
305
|
-
if (expanding[id] === p)
|
306
|
-
expanding[id]
|
417
|
+
if (expanding[id] === p) {
|
418
|
+
delete expanding[id];
|
419
|
+
Object.keys(expanding).forEach(function(parentId) {
|
420
|
+
ts.parents[parentId] = true;
|
421
|
+
});
|
422
|
+
}
|
307
423
|
continue;
|
308
424
|
}
|
309
|
-
|
310
|
-
var ts = tabstops[id];
|
311
|
-
var arg = typeof ts.value == "string" ? [ts.value] : copyValue(ts.value);
|
312
|
-
arg.unshift(i + 1, Math.max(0, i1 - i));
|
313
|
-
arg.push(p);
|
314
425
|
expanding[id] = p;
|
315
|
-
|
426
|
+
var value = ts.value;
|
427
|
+
if (typeof value !== "string")
|
428
|
+
value = copyValue(value);
|
429
|
+
else if (p.fmt)
|
430
|
+
value = this.tmStrFormat(value, p, editor);
|
431
|
+
tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p));
|
316
432
|
|
317
433
|
if (ts.indexOf(p) === -1)
|
318
434
|
ts.push(p);
|
@@ -328,7 +444,7 @@ var SnippetManager = function() {
|
|
328
444
|
} else
|
329
445
|
column += t.length;
|
330
446
|
text += t;
|
331
|
-
} else {
|
447
|
+
} else if (t) {
|
332
448
|
if (!t.start)
|
333
449
|
t.start = {row: row, column: column};
|
334
450
|
else
|
@@ -630,66 +746,43 @@ var TabstopManager = function(editor) {
|
|
630
746
|
};
|
631
747
|
|
632
748
|
this.onChange = function(delta) {
|
633
|
-
var changeRange = delta;
|
634
749
|
var isRemove = delta.action[0] == "r";
|
635
|
-
var
|
636
|
-
var
|
637
|
-
var
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
if (changedOutside)
|
652
|
-
return this.detach();
|
653
|
-
}
|
654
|
-
var ranges = this.ranges;
|
655
|
-
for (var i = 0; i < ranges.length; i++) {
|
656
|
-
var r = ranges[i];
|
657
|
-
if (r.end.row < start.row)
|
658
|
-
continue;
|
659
|
-
|
660
|
-
if (isRemove && comparePoints(start, r.start) < 0 && comparePoints(end, r.end) > 0) {
|
661
|
-
this.removeRange(r);
|
662
|
-
i--;
|
663
|
-
continue;
|
750
|
+
var parents = this.selectedTabstop && this.selectedTabstop.parents || {};
|
751
|
+
var tabstops = (this.tabstops || []).slice();
|
752
|
+
for (var i = 0; i < tabstops.length; i++) {
|
753
|
+
var ts = tabstops[i];
|
754
|
+
var active = ts == this.selectedTabstop || parents[ts.index];
|
755
|
+
ts.rangeList.$bias = active ? 0 : 1;
|
756
|
+
|
757
|
+
if (delta.action == "remove" && ts !== this.selectedTabstop) {
|
758
|
+
var parentActive = ts.parents && ts.parents[this.selectedTabstop.index];
|
759
|
+
var startIndex = ts.rangeList.pointIndex(delta.start, parentActive);
|
760
|
+
startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1;
|
761
|
+
var endIndex = ts.rangeList.pointIndex(delta.end, parentActive);
|
762
|
+
endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1;
|
763
|
+
var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex);
|
764
|
+
for (var j = 0; j < toRemove.length; j++)
|
765
|
+
this.removeRange(toRemove[j]);
|
664
766
|
}
|
665
|
-
|
666
|
-
if (r.start.row == startRow && r.start.column > start.column)
|
667
|
-
r.start.column += colDiff;
|
668
|
-
if (r.end.row == startRow && r.end.column >= start.column)
|
669
|
-
r.end.column += colDiff;
|
670
|
-
if (r.start.row >= startRow)
|
671
|
-
r.start.row += lineDif;
|
672
|
-
if (r.end.row >= startRow)
|
673
|
-
r.end.row += lineDif;
|
674
|
-
|
675
|
-
if (comparePoints(r.start, r.end) > 0)
|
676
|
-
this.removeRange(r);
|
767
|
+
ts.rangeList.$onChange(delta);
|
677
768
|
}
|
678
|
-
|
769
|
+
var session = this.editor.session;
|
770
|
+
if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue())
|
679
771
|
this.detach();
|
680
772
|
};
|
681
773
|
this.updateLinkedFields = function() {
|
682
774
|
var ts = this.selectedTabstop;
|
683
|
-
if (!ts || !ts.hasLinkedRanges)
|
775
|
+
if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked)
|
684
776
|
return;
|
685
777
|
this.$inChange = true;
|
686
778
|
var session = this.editor.session;
|
687
779
|
var text = session.getTextRange(ts.firstNonLinked);
|
688
|
-
for (var i = ts.length; i
|
780
|
+
for (var i = 0; i < ts.length; i++) {
|
689
781
|
var range = ts[i];
|
690
782
|
if (!range.linked)
|
691
783
|
continue;
|
692
|
-
var
|
784
|
+
var original = range.original;
|
785
|
+
var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor);
|
693
786
|
session.replace(range, fmt);
|
694
787
|
}
|
695
788
|
this.$inChange = false;
|
@@ -704,7 +797,7 @@ var TabstopManager = function(editor) {
|
|
704
797
|
var lead = this.editor.selection.lead;
|
705
798
|
var anchor = this.editor.selection.anchor;
|
706
799
|
var isEmpty = this.editor.selection.isEmpty();
|
707
|
-
for (var i = this.ranges.length; i
|
800
|
+
for (var i = 0; i < this.ranges.length; i++) {
|
708
801
|
if (this.ranges[i].linked)
|
709
802
|
continue;
|
710
803
|
var containsLead = this.ranges[i].contains(lead.row, lead.column);
|
@@ -738,10 +831,11 @@ var TabstopManager = function(editor) {
|
|
738
831
|
return;
|
739
832
|
|
740
833
|
this.selectedTabstop = ts;
|
741
|
-
|
834
|
+
var range = ts.firstNonLinked || ts;
|
835
|
+
if (!this.editor.inVirtualSelectionMode) {
|
742
836
|
var sel = this.editor.multiSelect;
|
743
|
-
sel.toSingleRange(
|
744
|
-
for (var i = ts.length; i
|
837
|
+
sel.toSingleRange(range.clone());
|
838
|
+
for (var i = 0; i < ts.length; i++) {
|
745
839
|
if (ts.hasLinkedRanges && ts[i].linked)
|
746
840
|
continue;
|
747
841
|
sel.addRange(ts[i].clone(), true);
|
@@ -749,12 +843,16 @@ var TabstopManager = function(editor) {
|
|
749
843
|
if (sel.ranges[0])
|
750
844
|
sel.addRange(sel.ranges[0].clone());
|
751
845
|
} else {
|
752
|
-
this.editor.selection.setRange(
|
846
|
+
this.editor.selection.setRange(range);
|
753
847
|
}
|
754
848
|
|
755
849
|
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
850
|
+
if (this.selectedTabstop && this.selectedTabstop.choices)
|
851
|
+
this.editor.execCommand("startAutocomplete", {matches: this.selectedTabstop.choices});
|
756
852
|
};
|
757
853
|
this.addTabstops = function(tabstops, start, end) {
|
854
|
+
var useLink = this.useLink || !this.editor.getOption("enableMultiselect");
|
855
|
+
|
758
856
|
if (!this.$openTabstops)
|
759
857
|
this.$openTabstops = [];
|
760
858
|
if (!tabstops[0]) {
|
@@ -770,8 +868,10 @@ var TabstopManager = function(editor) {
|
|
770
868
|
var ranges = this.ranges;
|
771
869
|
tabstops.forEach(function(ts, index) {
|
772
870
|
var dest = this.$openTabstops[index] || ts;
|
773
|
-
|
774
|
-
|
871
|
+
ts.rangeList = new RangeList();
|
872
|
+
ts.rangeList.$bias = 0;
|
873
|
+
|
874
|
+
for (var i = 0; i < ts.length; i++) {
|
775
875
|
var p = ts[i];
|
776
876
|
var range = Range.fromPoints(p.start, p.end || p.start);
|
777
877
|
movePoint(range.start, start);
|
@@ -779,11 +879,12 @@ var TabstopManager = function(editor) {
|
|
779
879
|
range.original = p;
|
780
880
|
range.tabstop = dest;
|
781
881
|
ranges.push(range);
|
882
|
+
ts.rangeList.ranges.push(range);
|
782
883
|
if (dest != ts)
|
783
884
|
dest.unshift(range);
|
784
885
|
else
|
785
886
|
dest[i] = range;
|
786
|
-
if (p.fmtString) {
|
887
|
+
if (p.fmtString || (dest.firstNonLinked && useLink)) {
|
787
888
|
range.linked = true;
|
788
889
|
dest.hasLinkedRanges = true;
|
789
890
|
} else if (!dest.firstNonLinked)
|
@@ -821,9 +922,11 @@ var TabstopManager = function(editor) {
|
|
821
922
|
};
|
822
923
|
this.removeRange = function(range) {
|
823
924
|
var i = range.tabstop.indexOf(range);
|
824
|
-
range.tabstop.splice(i, 1);
|
925
|
+
if (i != -1) range.tabstop.splice(i, 1);
|
825
926
|
i = this.ranges.indexOf(range);
|
826
|
-
this.ranges.splice(i, 1);
|
927
|
+
if (i != -1) this.ranges.splice(i, 1);
|
928
|
+
i = range.tabstop.rangeList.ranges.indexOf(range);
|
929
|
+
if (i != -1) range.tabstop.splice(i, 1);
|
827
930
|
this.editor.session.removeMarker(range.markerId);
|
828
931
|
if (!range.tabstop.length) {
|
829
932
|
i = this.tabstops.indexOf(range.tabstop);
|
@@ -857,18 +960,6 @@ var TabstopManager = function(editor) {
|
|
857
960
|
|
858
961
|
|
859
962
|
|
860
|
-
var changeTracker = {};
|
861
|
-
changeTracker.onChange = Anchor.prototype.onChange;
|
862
|
-
changeTracker.setPosition = function(row, column) {
|
863
|
-
this.pos.row = row;
|
864
|
-
this.pos.column = column;
|
865
|
-
};
|
866
|
-
changeTracker.update = function(pos, delta, $insertRight) {
|
867
|
-
this.$insertRight = $insertRight;
|
868
|
-
this.pos = pos;
|
869
|
-
this.onChange(delta);
|
870
|
-
};
|
871
|
-
|
872
963
|
var movePoint = function(point, diff) {
|
873
964
|
if (point.row == 0)
|
874
965
|
point.column += diff.column;
|
@@ -906,12 +997,13 @@ var Editor = require("./editor").Editor;
|
|
906
997
|
|
907
998
|
});
|
908
999
|
|
909
|
-
define("ace/ext/emmet",["require","exports","module","ace/keyboard/hash_handler","ace/editor","ace/snippets","ace/range","resources","resources","tabStops","resources","utils","actions"
|
1000
|
+
define("ace/ext/emmet",["require","exports","module","ace/keyboard/hash_handler","ace/editor","ace/snippets","ace/range","ace/config","resources","resources","tabStops","resources","utils","actions"], function(require, exports, module) {
|
910
1001
|
"use strict";
|
911
|
-
var HashHandler = require("
|
912
|
-
var Editor = require("
|
913
|
-
var snippetManager = require("
|
914
|
-
var Range = require("
|
1002
|
+
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
1003
|
+
var Editor = require("../editor").Editor;
|
1004
|
+
var snippetManager = require("../snippets").snippetManager;
|
1005
|
+
var Range = require("../range").Range;
|
1006
|
+
var config = require("../config");
|
915
1007
|
var emmet, emmetPath;
|
916
1008
|
function AceEmmetEditor() {}
|
917
1009
|
|
@@ -1019,7 +1111,7 @@ AceEmmetEditor.prototype = {
|
|
1019
1111
|
}
|
1020
1112
|
},
|
1021
1113
|
prompt: function(title) {
|
1022
|
-
return prompt(title);
|
1114
|
+
return prompt(title); // eslint-disable-line no-alert
|
1023
1115
|
},
|
1024
1116
|
getSelection: function() {
|
1025
1117
|
return this.ace.session.getTextRange();
|
@@ -1106,18 +1198,17 @@ var keymap = {
|
|
1106
1198
|
var editorProxy = new AceEmmetEditor();
|
1107
1199
|
exports.commands = new HashHandler();
|
1108
1200
|
exports.runEmmetCommand = function runEmmetCommand(editor) {
|
1201
|
+
if (this.action == "expand_abbreviation_with_tab") {
|
1202
|
+
if (!editor.selection.isEmpty())
|
1203
|
+
return false;
|
1204
|
+
var pos = editor.selection.lead;
|
1205
|
+
var token = editor.session.getTokenAt(pos.row, pos.column);
|
1206
|
+
if (token && /\btag\b/.test(token.type))
|
1207
|
+
return false;
|
1208
|
+
}
|
1109
1209
|
try {
|
1110
1210
|
editorProxy.setupContext(editor);
|
1111
1211
|
var actions = emmet.actions || emmet.require("actions");
|
1112
|
-
|
1113
|
-
if (this.action == "expand_abbreviation_with_tab") {
|
1114
|
-
if (!editor.selection.isEmpty())
|
1115
|
-
return false;
|
1116
|
-
var pos = editor.selection.lead;
|
1117
|
-
var token = editor.session.getTokenAt(pos.row, pos.column);
|
1118
|
-
if (token && /\btag\b/.test(token.type))
|
1119
|
-
return false;
|
1120
|
-
}
|
1121
1212
|
|
1122
1213
|
if (this.action == "wrap_with_abbreviation") {
|
1123
1214
|
return setTimeout(function() {
|
@@ -1128,11 +1219,13 @@ exports.runEmmetCommand = function runEmmetCommand(editor) {
|
|
1128
1219
|
var result = actions.run(this.action, editorProxy);
|
1129
1220
|
} catch(e) {
|
1130
1221
|
if (!emmet) {
|
1131
|
-
exports.load(runEmmetCommand.bind(this, editor));
|
1132
|
-
|
1222
|
+
var loading = exports.load(runEmmetCommand.bind(this, editor));
|
1223
|
+
if (this.action == "expand_abbreviation_with_tab")
|
1224
|
+
return false;
|
1225
|
+
return loading;
|
1133
1226
|
}
|
1134
1227
|
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
|
1135
|
-
|
1228
|
+
config.warn(e);
|
1136
1229
|
result = false;
|
1137
1230
|
}
|
1138
1231
|
return result;
|
@@ -1191,16 +1284,19 @@ var onChangeMode = function(e, target) {
|
|
1191
1284
|
};
|
1192
1285
|
|
1193
1286
|
exports.load = function(cb) {
|
1194
|
-
if (typeof emmetPath
|
1195
|
-
|
1196
|
-
|
1197
|
-
cb && cb();
|
1198
|
-
});
|
1287
|
+
if (typeof emmetPath !== "string") {
|
1288
|
+
config.warn("script for emmet-core is not loaded");
|
1289
|
+
return false;
|
1199
1290
|
}
|
1291
|
+
config.loadModule(emmetPath, function() {
|
1292
|
+
emmetPath = null;
|
1293
|
+
cb && cb();
|
1294
|
+
});
|
1295
|
+
return true;
|
1200
1296
|
};
|
1201
1297
|
|
1202
1298
|
exports.AceEmmetEditor = AceEmmetEditor;
|
1203
|
-
|
1299
|
+
config.defineOptions(Editor.prototype, "editor", {
|
1204
1300
|
enableEmmet: {
|
1205
1301
|
set: function(val) {
|
1206
1302
|
this[val ? "on" : "removeListener"]("changeMode", onChangeMode);
|