Fix incorrect agent names in autocomplete list [#27]

This commit is contained in:
David Evans 2017-11-22 19:21:38 +00:00
parent ece11167f3
commit 25a01fea6b
1 changed files with 25 additions and 10 deletions

View File

@ -325,15 +325,18 @@ define(['core/ArrayUtilities'], (array) => {
} }
array.mergeSets( array.mergeSets(
state['known' + locals.type], state['known' + locals.type],
[locals.value] [locals.value + ' ']
); );
locals.type = ''; locals.type = '';
} else { locals.value = '';
locals.value += token + ' ';
} }
} else if(typeof suggest === 'string' && state['known' + suggest]) { }
if(typeof suggest === 'string' && state['known' + suggest]) {
locals.type = suggest; locals.type = suggest;
locals.value = token + ' '; if(locals.value) {
locals.value += token.s;
}
locals.value += token.v;
} }
} }
@ -357,10 +360,10 @@ define(['core/ArrayUtilities'], (array) => {
path.push(found || CM_ERROR); path.push(found || CM_ERROR);
} }
current = array.last(path); current = array.last(path);
updateSuggestion(state, suggestions, token.v, current); updateSuggestion(state, suggestions, token, current);
}); });
if(eol) { if(eol) {
updateSuggestion(state, suggestions, '', {}); updateSuggestion(state, suggestions, null, {});
} }
state.nextCompletions = cmMakeCompletions(state, path); state.nextCompletions = cmMakeCompletions(state, path);
state.valid = ( state.valid = (
@ -389,6 +392,7 @@ define(['core/ArrayUtilities'], (array) => {
return { return {
currentType: -1, currentType: -1,
current: '', current: '',
currentSpace: '',
currentQuoted: false, currentQuoted: false,
knownAgent: [], knownAgent: [],
knownLabel: [], knownLabel: [],
@ -410,10 +414,13 @@ define(['core/ArrayUtilities'], (array) => {
} }
_tokenBegin(stream, state) { _tokenBegin(stream, state) {
state.currentSpace = '';
let lastChar = '';
while(true) { while(true) {
if(stream.eol()) { if(stream.eol()) {
return false; return false;
} }
state.currentSpace += lastChar;
for(let i = 0; i < this.tokenDefinitions.length; ++ i) { for(let i = 0; i < this.tokenDefinitions.length; ++ i) {
const block = this.tokenDefinitions[i]; const block = this.tokenDefinitions[i];
if(this._matchPattern(stream, block.start, true)) { if(this._matchPattern(stream, block.start, true)) {
@ -424,7 +431,7 @@ define(['core/ArrayUtilities'], (array) => {
return true; return true;
} }
} }
stream.next(); lastChar = stream.next();
} }
} }
@ -435,12 +442,20 @@ define(['core/ArrayUtilities'], (array) => {
} }
} }
_addToken(state) {
state.line.push({
v: state.current,
s: state.currentSpace,
q: state.currentQuoted,
});
}
_tokenEndFound(stream, state, block) { _tokenEndFound(stream, state, block) {
state.currentType = -1; state.currentType = -1;
if(block.omit) { if(block.omit) {
return 'comment'; return 'comment';
} }
state.line.push({v: state.current, q: state.currentQuoted}); this._addToken(state);
return cmCheckToken(state, stream.eol(), this.commands); return cmCheckToken(state, stream.eol(), this.commands);
} }
@ -449,7 +464,7 @@ define(['core/ArrayUtilities'], (array) => {
if(block.omit) { if(block.omit) {
return 'comment'; return 'comment';
} }
state.line.push(({v: state.current, q: state.currentQuoted})); this._addToken(state);
const type = cmCheckToken(state, false, this.commands); const type = cmCheckToken(state, false, this.commands);
state.line.pop(); state.line.pop();
return type; return type;