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

Commit

Permalink
fix: fix grammar condition when substring of editor grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Mar 25, 2021
1 parent a118f42 commit 3618f34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/flex-tool-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ export default {
grammarCondition(condition) {
this.conditionTypes.grammar = true;
return this.reversableStringCondition(condition, (c) => {
return this.activeItem && this.activeItem.grammar && this.activeItem.grammar.includes(c.toLowerCase());
return this.activeItem && this.activeItem.grammar && this.activeItem.grammar === c.toLowerCase();
});
},

Expand Down
18 changes: 18 additions & 0 deletions spec/flex-tool-bar-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,24 @@ describe('FlexToolBar', function () {
expect(match).toBe(true);
expect(notMatch).toBe(false);
});

it('should not match substring', function () {
flexToolBar.activeItem.grammar = 'cpp';

const match = flexToolBar.checkConditions({grammar: 'c'});
const notMatch = flexToolBar.checkConditions({grammar: '!c'});
expect(match).toBe(false);
expect(notMatch).toBe(true);
});

it('should not match grammar substring', function () {
flexToolBar.activeItem.grammar = 'c';

const match = flexToolBar.checkConditions({grammar: 'cpp'});
const notMatch = flexToolBar.checkConditions({grammar: '!cpp'});
expect(match).toBe(false);
expect(notMatch).toBe(true);
});
});

describe('pattern condition', function () {
Expand Down

0 comments on commit 3618f34

Please sign in to comment.