@@ -95,7 +95,33 @@ class TopBar extends React.Component {
9595 if ( search . trim ( ) . length === 0 ) return [ ]
9696 let searchBlocks = search . split ( ' ' )
9797 searchBlocks . forEach ( ( block ) => {
98- if ( block . match ( / ^ # .+ / ) ) {
98+ if ( block . match ( / ^ ! # .+ / ) ) {
99+ let tag = block . match ( / ^ ! # ( .+ ) / ) [ 1 ]
100+ let regExp = new RegExp ( _ . escapeRegExp ( tag ) , 'i' )
101+ notes = notes
102+ . filter ( ( note ) => {
103+ if ( ! _ . isArray ( note . tags ) ) return false
104+ return note . tags . some ( ( _tag ) => {
105+ return _tag . match ( regExp )
106+ } )
107+ } )
108+ } else if ( block . match ( / ^ ! .+ / ) ) {
109+ let block = block . match ( / ^ ! ( .+ ) / ) [ 1 ]
110+ let regExp = new RegExp ( _ . escapeRegExp ( block ) , 'i' )
111+ notes = notes . filter ( ( note ) => {
112+ if ( ! _ . isArray ( note . tags ) || ! note . tags . some ( ( _tag ) => {
113+ return _tag . match ( regExp )
114+ } ) ) {
115+ return true
116+ }
117+ if ( note . type === 'SNIPPET_NOTE' ) {
118+ return ! note . description . match ( regExp )
119+ } else if ( note . type === 'MARKDOWN_NOTE' ) {
120+ return ! note . content . match ( regExp )
121+ }
122+ return false
123+ } )
124+ } else if ( block . match ( / ^ # .+ / ) ) {
99125 let tag = block . match ( / # ( .+ ) / ) [ 1 ]
100126 let regExp = new RegExp ( _ . escapeRegExp ( tag ) , 'i' )
101127 notes = notes
@@ -108,6 +134,11 @@ class TopBar extends React.Component {
108134 } else {
109135 let regExp = new RegExp ( _ . escapeRegExp ( block ) , 'i' )
110136 notes = notes . filter ( ( note ) => {
137+ if ( _ . isArray ( note . tags ) && note . tags . some ( ( _tag ) => {
138+ return _tag . match ( regExp )
139+ } ) ) {
140+ return true
141+ }
111142 if ( note . type === 'SNIPPET_NOTE' ) {
112143 return note . description . match ( regExp )
113144 } else if ( note . type === 'MARKDOWN_NOTE' ) {
0 commit comments