Browse Source

fix: AC tree on columns after an opening curly bracket

pull/2160/head
Wing-Kam Wong 3 years ago
parent
commit
ad26dda3ed
  1. 9
      packages/nc-gui/components/project/spreadsheet/components/editColumn/FormulaOptions.vue

9
packages/nc-gui/components/project/spreadsheet/components/editColumn/FormulaOptions.vue

@ -568,14 +568,13 @@ export default {
this.selected = 0 this.selected = 0
this.suggestion = null this.suggestion = null
const query = getWordUntilCaret(this.$refs.input.$el.querySelector('input')) const query = getWordUntilCaret(this.$refs.input.$el.querySelector('input'))
// count number of opening curly brackets and closing curly brackets
const cntCurlyBrackets = (this.$refs.input.$el.querySelector('input').value.match(/\{|}/g) || []).reduce((acc, cur) => (acc[cur] = (acc[cur] || 0) + 1, acc), {})
if (Math.abs((cntCurlyBrackets['{'] || 0) - (cntCurlyBrackets['}'] || 0))) {
this.suggestion = this.suggestionsList.filter(v => v.type === 'column')
} else {
const parts = query.split(/\W+/) const parts = query.split(/\W+/)
this.wordToComplete = parts.pop() this.wordToComplete = parts.pop()
this.suggestion = this.acTree.complete(this.wordToComplete)?.sort((x, y) => this.sortOrder[x.type] - this.sortOrder[y.type]) this.suggestion = this.acTree.complete(this.wordToComplete)?.sort((x, y) => this.sortOrder[x.type] - this.sortOrder[y.type])
// count number of opening curly brackets and closing curly brackets
const cntCurlyBrackets = (this.$refs.input.$el.querySelector('input').value.match(/\{|}/g) || []).reduce((acc, cur) => (acc[cur] = (acc[cur] || 0) + 1, acc), {})
if (Math.abs((cntCurlyBrackets['{'] || 0) - (cntCurlyBrackets['}'] || 0))) {
this.suggestion = this.suggestion.filter(v => v.type === 'column')
} }
this.autocomplete = !!this.suggestion.length this.autocomplete = !!this.suggestion.length
}, },

Loading…
Cancel
Save