Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ajaxorg/ace
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.31.1
Choose a base ref
...
head repository: ajaxorg/ace
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.31.2
Choose a head ref
  • 15 commits
  • 11 files changed
  • 6 contributors

Commits on Nov 1, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b70fb4f View commit details

Commits on Nov 2, 2023

  1. Copy the full SHA
    c950377 View commit details
  2. Merge pull request #5376 from ajaxorg/nojekyll

    disable jekyll for gh-pages
    nightwing authored Nov 2, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4f25d59 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2138796 View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f21dfe8 View commit details

Commits on Nov 14, 2023

  1. Copy the full SHA
    05db94f View commit details
  2. add tests for fixes

    akoreman committed Nov 14, 2023
    Copy the full SHA
    15a8f3e View commit details
  3. Copy the full SHA
    d50d019 View commit details
  4. typo

    akoreman committed Nov 14, 2023
    Copy the full SHA
    05a70af View commit details
  5. Copy the full SHA
    7d275e8 View commit details
  6. Copy the full SHA
    c634902 View commit details

Commits on Nov 15, 2023

  1. lint fix

    akoreman committed Nov 15, 2023
    Copy the full SHA
    8e6e420 View commit details
  2. remove semicolon

    akoreman committed Nov 15, 2023
    Copy the full SHA
    4f1ad2c View commit details
  3. Merge pull request #5393 from akoreman/loading_state_fix

    Fixes three small issues with the completion loading state we recently added (#5368):
    
        When showing the 'no suggestions' state after the loading state the loading animation should not be rendered on the 'no suggestions state'.
        With inline preview enabled, the result that is selected after the loading state disappears should show inline preview.
        Keeps the Loading... item in the popup as long as not all completers are finished, this allows screen reader users to find out when/if the loading has finished.
    
    Additionally puts the completion loading state behind an option flag.
    akoreman authored Nov 15, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f078e3e View commit details
  4. release v1.31.2

    akoreman committed Nov 15, 2023
    Copy the full SHA
    0d425b3 View commit details
Showing with 166 additions and 21 deletions.
  1. +1 −0 .nojekyll
  2. +7 −0 CHANGELOG.md
  3. +1 −0 ace.d.ts
  4. +1 −1 build
  5. +4 −0 index.html
  6. +5 −2 lib/ace/mode/xml/sax.js
  7. +1 −1 package.json
  8. +38 −14 src/autocomplete.js
  9. +105 −1 src/autocomplete_test.js
  10. +1 −1 src/config.js
  11. +2 −1 src/mode/prql_highlight_rules.js
1 change: 1 addition & 0 deletions .nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable jekyll on gh-pages
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.31.2](https://github.com/ajaxorg/ace/compare/v1.31.1...v1.31.2) (2023-11-15)


### Bug Fixes

* inline preview with loading state ([05db94f](https://github.com/ajaxorg/ace/commit/05db94f53774f64318de757347f7217043744fe6))

### [1.31.1](https://github.com/ajaxorg/ace/compare/v1.31.0...v1.31.1) (2023-10-30)


1 change: 1 addition & 0 deletions ace.d.ts
Original file line number Diff line number Diff line change
@@ -1071,6 +1071,7 @@ export namespace Ace {
setSelectOnHover?: Boolean;
stickySelectionDelay?: Number;
ignoreCaption?: Boolean;
showLoadingState?: Boolean;
emptyMessage?(prefix: String): String;
getPopup(): AcePopup;
showPopup(editor: Editor, options: CompletionOptions): void;
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1158,6 +1158,10 @@ <h1>Projects Using Ace</h1>
<img lazy-src="https://aijs.io/aijsv4.png" style="width: 85px; left: 7px; top: -7px;">
<a href="https://aijs.io/editor">AIJS</a>
</li>
<li>
<img lazy-src="https://k8studio.io/static/images/logo.png" style="width: 85px; left: 7px; top: -7px;">
<a href="https://k8studio.io/">K8Studio</a>
</li>
<li id="add_your_site">
<p>+</p>
<a href="https://github.com/ajaxorg/ace/issues/new?assignees=&labels=website%2Cneeds-triage&projects=&template=add-to-website.yml&title=Add+project+%28project+name%29+to+the+list+of+projects+using+Ace+on+its+website">Your Site Here</a>
7 changes: 5 additions & 2 deletions lib/ace/mode/xml/sax.js
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
errorHandler.warning('unclosed xml attribute');
}
}
appendElement(el,domBuilder,parseStack);
appendElement(el,domBuilder,parseStack,errorHandler);


if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
@@ -347,7 +347,7 @@ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
/**
* @return end of the elementStartPart(end of elementEndPart for selfClosed el)
*/
function appendElement(el,domBuilder,parseStack){
function appendElement(el,domBuilder,parseStack,errorHandler){
var tagName = el.tagName;
var localNSMap = null;
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
@@ -405,6 +405,9 @@ function appendElement(el,domBuilder,parseStack){
}
//no prefix element has default namespace
var ns = el.uri = currentNSMap[prefix || ''];
if (prefix && !ns) {
errorHandler.error('unexpected namespace ' + prefix);
}
domBuilder.startElement(ns,localName,tagName,el);
//endPrefixMapping and startPrefixMapping have not any help for dom builder
//localNSMap = null
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ace-code",
"description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE",
"version": "1.31.1",
"version": "1.31.2",
"homepage": "http://github.com/ajaxorg/ace",
"engines": {
"node": ">= 0.6.0"
52 changes: 38 additions & 14 deletions src/autocomplete.js
Original file line number Diff line number Diff line change
@@ -64,6 +64,14 @@ class Autocomplete {
this.parentNode = null;
this.setSelectOnHover = false;

/**
* @property {Boolean} showLoadingState - A boolean indicating whether the loading states of the Autocompletion should be shown to the end-user. If enabled
* it shows a loading indicator on the popup while autocomplete is loading.
*
* Experimental: This visualisation is not yet considered stable and might change in the future.
*/
this.showLoadingState = false;

/**
* @property {number} stickySelectionDelay - a numerical value that determines after how many ms the popup selection will become 'sticky'.
* Normally, when new elements are added to an open popup, the selection is reset to the first row of the popup. If sticky, the focus will remain
@@ -91,16 +99,18 @@ class Autocomplete {
var initialPosition = this.completionProvider && this.completionProvider.initialPosition;
if (this.autoShown || (this.popup && this.popup.isOpen) || !initialPosition) return;

var completionsForEmpty = [{
caption: config.nls("Loading..."),
value: ""
}];
this.completions = new FilteredList(completionsForEmpty);
this.completions = new FilteredList(Autocomplete.completionsForLoading);
this.openPopup(this.editor, initialPosition.prefix, false);
this.popup.renderer.setStyle("ace_loading", true);
}.bind(this), this.stickySelectionDelay);
}

static get completionsForLoading() { return [{
caption: config.nls("Loading..."),
value: ""
}];
}

$init() {
this.popup = new AcePopup(this.parentNode || document.body || document.documentElement);
this.popup.on("click", function(e) {
@@ -238,7 +248,8 @@ class Autocomplete {
this.popup.autoSelect = this.autoSelect;
this.popup.setSelectOnHover(this.setSelectOnHover);

var previousSelectedItem = this.popup.data[this.popup.getRow()];
var oldRow = this.popup.getRow();
var previousSelectedItem = this.popup.data[oldRow];

this.popup.setData(this.completions.filtered, this.completions.filterText);
if (this.editor.textInput.setAriaOptions) {
@@ -250,12 +261,17 @@ class Autocomplete {

editor.keyBinding.addKeyboardHandler(this.keyboardHandler);

var newRow = this.popup.data.indexOf(previousSelectedItem);

if (newRow && this.stickySelection)
this.popup.setRow(this.autoSelect ? newRow : -1);
else
this.popup.setRow(this.autoSelect ? 0 : -1);
var newRow;
if (this.stickySelection)
newRow = this.popup.data.indexOf(previousSelectedItem);
if (!newRow || newRow === -1)
newRow = 0;

this.popup.setRow(this.autoSelect ? newRow : -1);

// If we stay on the same row, but the content is different, we want to update the popup.
if (newRow === oldRow && previousSelectedItem !== this.completions.filtered[newRow])
this.$onPopupChange();

if (!keepPopupPosition) {
this.popup.setTheme(editor.getTheme());
@@ -458,6 +474,7 @@ class Autocomplete {
}];
this.completions = new FilteredList(completionsForEmpty);
this.openPopup(this.editor, prefix, keepPopupPosition);
this.popup.renderer.setStyle("ace_loading", false);
return;
}
return this.detach();
@@ -471,13 +488,20 @@ class Autocomplete {
if (this.autoInsert && !this.autoShown && filtered.length == 1)
return this.insertMatch(filtered[0]);
}
this.completions = completions;
// If showLoadingState is true and there is still a completer loading, show 'Loading...'
// in the top row of the completer popup.
this.completions = !finished && this.showLoadingState ?
new FilteredList(
Autocomplete.completionsForLoading.concat(filtered), completions.filterText
) :
completions;

this.openPopup(this.editor, prefix, keepPopupPosition);

this.popup.renderer.setStyle("ace_loading", !finished);
}.bind(this));

if (!this.autoShown && !(this.popup && this.popup.isOpen)) {
if (this.showLoadingState && !this.autoShown && !(this.popup && this.popup.isOpen)) {
this.$firstOpenTimer.delay(this.stickySelectionDelay/2);
}
}
106 changes: 105 additions & 1 deletion src/autocomplete_test.js
Original file line number Diff line number Diff line change
@@ -989,6 +989,7 @@ module.exports = {

var completer = Autocomplete.for(editor);
completer.stickySelectionDelay = 100;
completer.showLoadingState = true;
user.type("Ctrl-Space");
assert.ok(!(completer.popup && completer.popup.isOpen));

@@ -1005,8 +1006,11 @@ module.exports = {

editor.completers = [fastCompleter, slowCompleter];
user.type("Ctrl-Space");
assert.equal(completer.popup.data.length, 3);
assert.equal(completer.popup.data.length, 4);

// Should have top row saying 'Loading...' together with results.
assert.ok(isLoading());
assert.equal(completer.popup.data[0].caption, "Loading...");
setTimeout(() => {
completer.popup.renderer.$loop._flush();
assert.equal(completer.popup.data.length, 5);
@@ -1016,6 +1020,106 @@ module.exports = {
}, 150);
}, 100);

function isLoading() {
return completer.popup.renderer.container.classList.contains("ace_loading");
}
},
"test: should not display loading state on no suggestion state": function(done) {
var editor = initEditor("hello world\n");

var slowCompleter = {
getCompletions: function (editor, session, pos, prefix, callback) {
var completions = [
{
caption: "slow option 1",
value: "s1",
score: 3
}, {
caption: "slow option 2",
value: "s2",
score: 0
}
];
setTimeout(() => {
callback(null, completions);
}, 200);
}
};

editor.completers = [slowCompleter];

var completer = Autocomplete.for(editor);
completer.stickySelectionDelay = 100;
completer.emptyMessage = "no completions";
completer.showLoadingState = true;

user.type("doesntmatchanything");
user.type("Ctrl-Space");
assert.ok(!(completer.popup && completer.popup.isOpen));

setTimeout(() => {
completer.popup.renderer.$loop._flush();
assert.equal(completer.popup.data.length, 1);
assert.ok(isLoading());
setTimeout(() => {
// Should show no suggestions state without loading indicator
assert.equal(completer.popup.data.length, 1);
assert.equal(completer.popup.data[0].caption, "no completions");
assert.ok(!isLoading());

done();
}, 150);
}, 100);

function isLoading() {
return completer.popup.renderer.container.classList.contains("ace_loading");
}
},
"test: should display ghost text after loading state if inline preview enabled": function(done) {
var editor = initEditor("hello world\n");

var slowCompleter = {
getCompletions: function (editor, session, pos, prefix, callback) {
var completions = [
{
caption: "slow option 1",
value: "s1",
score: 3
}, {
caption: "slow option 2",
value: "s2",
score: 0
}
];
setTimeout(() => {
callback(null, completions);
}, 200);
}
};

editor.completers = [slowCompleter];

var completer = Autocomplete.for(editor);
completer.stickySelectionDelay = 100;
completer.inlineEnabled = true;
completer.showLoadingState = true;

user.type("Ctrl-Space");
assert.ok(!(completer.popup && completer.popup.isOpen));

setTimeout(() => {
completer.popup.renderer.$loop._flush();
assert.equal(completer.popup.data.length, 1);
assert.ok(isLoading());
setTimeout(() => {
assert.equal(completer.popup.data.length, 2);
assert.ok(!isLoading());

assert.strictEqual(editor.renderer.$ghostText.text, "s1");
done();
}, 150);
}, 100);

function isLoading() {
return completer.popup.renderer.container.classList.contains("ace_loading");
}
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
@@ -168,6 +168,6 @@ var reportErrorIfPathIsNotConfigured = function() {
}
};

exports.version = "1.31.1";
exports.version = "1.31.2";


3 changes: 2 additions & 1 deletion src/mode/prql_highlight_rules.js
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ var PrqlHighlightRules = function() {
"int16",
"int32",
"int64",
"int128",
"float",
"text",
"set"].join("|");
@@ -35,7 +36,7 @@ var PrqlHighlightRules = function() {
"support.type": builtinTypes
}, "identifier");

var escapeRe = /\\(\d+|['"\\&bfnrt]|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2})/;
var escapeRe = /\\(\d+|['"\\&bfnrt]|u\{[0-9a-fA-F]{1,6}\}|x[0-9a-fA-F]{2})/;
var identifierRe = /[A-Za-z_][a-z_A-Z0-9]/.source;
var numRe = /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/.source;
var bidi = "[\\u202A\\u202B\\u202D\\u202E\\u2066\\u2067\\u2068\\u202C\\u2069]";