Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Compass 2934 don not autocomplete in comments #1

Merged
merged 8 commits into from
Jun 17, 2018

Conversation

alenakhineika
Copy link
Contributor

Don't do autocompletion when typing inside comments in the stage.

});
});

context('symbol before comment on the beginning of editor', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get one more test for multiline please? Something where the session is new EditSession('/**\n * query - The query in MQL.\n */ {}', new Mode()); and the position is { row: 1, column: 5 }?

@durran
Copy link
Member

durran commented Jun 13, 2018

Nice job - well tested. I think just the one multiline test to add and this is good to go. :)

value.slice(item.index + item[0].length)
].join('');
});

Copy link
Contributor Author

@alenakhineika alenakhineika Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have input like this:

{x: 'uuu//UU'} // $

we need to check if ´//´ is a real start tag of the comment, or it can be a part of a string. I couldn't create a single regex to handle it, therefore i replace stings like this which contain // with {x: #########} // $ and after it i can find real comments.

Copy link
Member

@durran durran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look great - just a few more changes so we are compatible with IE and for performance.

@@ -121,9 +121,42 @@ class StageAutoCompleter {
*
* @returns {Function} The completion function.
*/
getCompletions(editor, session, position, prefix, done) {
async getCompletions(editor, session, position, prefix, done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot use async/await as this will not be compatible with Cloud. They need to support IE.


// Comments block do not return results.
let value = session.getValue();
const findCommentsRe = new RegExp([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating the regex every time the hints are requested, I would move this to a constant so it's only created once at parse time.


const activePosition = session.getDocument().positionToIndex(position, 0);
let isComment = false;
const findCommnets = () => new Promise((resolve) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promises are also not supported in IE. Also typo here, should be findComments. But let's stick with standard callbacks for the autocomplete.

@durran durran merged commit b7cea14 into master Jun 17, 2018
@durran durran deleted the COMPASS-2934-don-not-autocomplete-in-comments branch June 17, 2018 11:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants