fix finding single note by label with mixed case

This commit is contained in:
zadam 2021-10-08 22:13:39 +02:00
parent a08690b123
commit 20696aa0ab
5 changed files with 17 additions and 5 deletions

View file

@ -29,7 +29,13 @@ class Becca {
/** @return {Attribute[]} */
findAttributes(type, name) {
return this.attributeIndex[`${type}-${name.toLowerCase()}`] || [];
name = name.trim().toLowerCase();
if (name.startsWith('#') || name.startsWith('~')) {
name = name.substr(1);
}
return this.attributeIndex[`${type}-${name}`] || [];
}
/** @return {Attribute[]} */

View file

@ -33,7 +33,8 @@ export default class EditedNotesWidget extends CollapsibleWidget {
getTitle() {
return {
show: this.isEnabled(),
activate: true,
// promoted attributes have priority over edited notes
activate: this.note.getPromotedDefinitionAttributes().length === 0,
title: 'Edited Notes',
icon: 'bx bx-calendar-edit'
};

View file

@ -75,8 +75,14 @@ function getNoteWithLabel(name, value) {
// optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes
const attrs = becca.findAttributes('label', name);
if (value === undefined) {
return attrs[0]?.getNote();
}
value = value?.toLowerCase();
for (const attr of attrs) {
if (attr.value === value) {
if (attr.value.toLowerCase() === value) {
return attr.getNote();
}
}

View file

@ -36,7 +36,6 @@ function getNoteStartingWith(parentNoteId, startsWith) {
/** @return {Note} */
function getRootCalendarNote() {
// some caching here could be useful (e.g. in CLS)
let rootNote = attributeService.getNoteWithLabel(CALENDAR_ROOT_LABEL);
if (!rootNote) {

View file

@ -19,7 +19,7 @@ class LabelComparisonExp extends Expression {
for (const attr of attrs) {
const note = attr.note;
const value = attr.value ? attr.value.toLowerCase() : attr.value;
const value = attr.value?.toLowerCase();
if (inputNoteSet.hasNoteId(note.noteId) && this.comparator(value)) {
if (attr.isInheritable) {