From f82c4df96a80a9c8b56f49be618f80a3a483b199 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 16 Jun 2013 21:06:40 +0400 Subject: [PATCH] [Autocomplete] fix insertion of words containing - sign --- lib/ace/autocomplete.js | 7 +++++-- lib/ace/autocomplete/util.js | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index fef14ff4..e00c8289 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -138,8 +138,11 @@ var Autocomplete = function() { } else { if (data.value) data = data.value; - if (this.completions.filterText) - this.editor.removeWordLeft(); + if (this.completions.filterText) { + var range = this.editor.selection.getRange(); + range.start.column -= this.completions.filterText.length; + this.editor.session.remove(range); + } this.editor.insert(data); } }; diff --git a/lib/ace/autocomplete/util.js b/lib/ace/autocomplete/util.js index ae9ece5d..8b7c1151 100644 --- a/lib/ace/autocomplete/util.js +++ b/lib/ace/autocomplete/util.js @@ -3,7 +3,7 @@ * * Copyright (c) 2012, Ajax.org B.V. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ * * Neither the name of Ajax.org B.V. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -32,20 +32,20 @@ define(function(require, exports, module) { "use strict"; exports.parForEach = function(array, fn, callback) { - var completed = 0; - var arLength = array.length; - if (arLength === 0) - callback(); - for (var i = 0; i < arLength; i++) { - fn(array[i], function(result, err) { - completed++; - if (completed === arLength) - callback(result, err); - }); - } + var completed = 0; + var arLength = array.length; + if (arLength === 0) + callback(); + for (var i = 0; i < arLength; i++) { + fn(array[i], function(result, err) { + completed++; + if (completed === arLength) + callback(result, err); + }); + } } -var ID_REGEX = /[a-zA-Z_0-9\$]/; +var ID_REGEX = /[a-zA-Z_0-9\$-]/; exports.retrievePrecedingIdentifier = function(text, pos, regex) { regex = regex || ID_REGEX;