Skip to content

Commit

Permalink
fix: can't search system tiddler because not remove leading $
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Jul 3, 2024
1 parent 4ff54e4 commit 2dcb672
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/commandpalette/language/en-GB/Translations.multids
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ Configs/ApplyIgnoreFilterToTag/Caption: Apply Ignore when searching for tags.
Configs/ApplyIgnoreFilterToTag/Description: When checked, the above filters are also applied when searching for sub-tiddlers of a tag through `#` mode. When ignore is in effect, the `- ... ` prompt.
Configs/DebounceDuration/Caption: Search debounce duration
Configs/DebounceDuration/Description: Pressing a key to search once will lead to lagging, here set the search anti-shake duration, meaning two consecutive key presses within this duration will be judged as inputting, and will wait for you to finish typing before searching, in milliseconds.
Configs/SearchSystemTitle/Caption: Freely Search System Tiddler Title
Configs/SearchSystemTitle/Description: There are a large number of system titles in the wiki that make up the Tiddlywiki operating system, and searching for them can be slow. Check this option if you are one of Tiddlywiki's developers and often search for system titles. (only involves free searching of system tiddlers, so you can search layouts, system actions, etc. without checking this option)
Configs/CacheSystemTiddlers/Caption: Caching system tiddlers
Configs/CacheSystemTiddlers/Description: Assumed system tiddlers don't change during wiki usage, so they are only loaded to the front-end cache once for the initial search, and then no longer loaded with the latest data for subsequent searches. Note that this option includes all results from searches done with {{$:/plugins/linonetwo/commandpalette/commands/help/System!!command-palette-prefix}}. If you are part of the developers of Tiddlywiki and the system tiddlers change frequently, then you can uncheck this option.
Configs/SearchSystemTitle/Caption: Search System Tiddler Title
Configs/SearchSystemTitle/Description: There are a large number of system titles in the wiki that make up the Tiddlywiki operating system, and searching for them can be slow. Check this option if you are one of Tiddlywiki's developers and often search for system titles.
Configs/CacheSystemTiddlers/Description: Assumed system tiddlers don't change during wiki usage, so they are only loaded to the front-end cache once for the initial search, and then no longer loaded with the latest data for subsequent searches. Note that this option includes all results from searches done with {{$:/plugins/linonetwo/commandpalette/commands/help/System!!command-palette-prefix}}. If you are part of the developers of Tiddlywiki and the system tiddlers change frequently, then you can uncheck this option. (only about search layout, system actions, etc., not about free search system tiddlers)
Configs/MissingFilterOnTop/Caption: missing filter on top
Configs/MissingFilterOnTop/Caption: Missing Filter On Top
Configs/MissingFilterOnTop/Description: When checked, when using `[` filter search mode, if there is no matching filter, it will be displayed on top, so that you can directly use the new filter you just entered to search. When unchecked, it will be at the bottom, so that you can search for the filter tiddlers tagged with `$:/tags/Filter`.
Configs/Appearance/Caption: Appearance
Expand Down
6 changes: 3 additions & 3 deletions src/commandpalette/language/zh-Hans/Translations.multids
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Configs/TitleTextIgnoreFilter/Caption: 标题和内容搜索时需要忽略的
Configs/TitleTextIgnoreFilter/Description: 通过筛选器指定不想在命令菜单里搜到的条目,例如可以通过日历搜索功能去搜的日记条目、可以通过别的插件专门管理的条目等。
Configs/ApplyIgnoreFilterToTag/Caption: 搜标签时也应用忽略
Configs/ApplyIgnoreFilterToTag/Description: 勾选时,通过 `#` 模式搜索某个标签的子条目时,也应用上述筛选器。忽略生效时,将显示 `- ...` 提示。
Configs/SearchSystemTitle/Caption: 自由搜索系统条目标题
Configs/SearchSystemTitle/Description: 知识库中有大量的系统条目,组成了太微操作系统,搜索它们会比较慢。如果您是太微的开发者的一员,经常搜索系统条目,那可以勾选此选项。(仅涉及自由搜索系统条目,所以不勾选此选项也可以搜索布局、系统动作等等)
Configs/CacheSystemTiddlers/Caption: 缓存系统条目
Configs/CacheSystemTiddlers/Description: 假设在知识库使用过程中,系统条目不会发生变化,所以只在初次搜索时加载一次到前端快取,之后再搜索时不再加载最新数据。注意此选项包括所有使用 {{$:/plugins/linonetwo/commandpalette/commands/help/System!!command-palette-prefix}} 搜索的结果。如果您是太微的开发者的一员,系统条目经常变化,那可以取消勾选此选项。
Configs/SearchSystemTitle/Caption: 搜索系统条目标题
Configs/SearchSystemTitle/Description: 知识库中有大量的系统条目,组成了太微操作系统,搜索它们会比较慢。如果您是太微的开发者的一员,经常搜索系统条目,那可以勾选此选项。
Configs/CacheSystemTiddlers/Description: 假设在知识库使用过程中,系统条目不会发生变化,所以只在初次搜索时加载一次到前端快取,之后再搜索时不再加载最新数据。注意此选项包括所有使用 {{$:/plugins/linonetwo/commandpalette/commands/help/System!!command-palette-prefix}} 搜索的结果。如果您是太微的开发者的一员,系统条目经常变化,那可以取消勾选此选项。(仅涉及搜索布局、系统动作等等,不涉及自由搜索系统条目)
Configs/MissingFilterOnTop/Caption: 缺失筛选器置顶
Configs/MissingFilterOnTop/Description: 勾选时,使用 `[` 筛选器搜索模式时,如果没有匹配的筛选器,则将其置顶显示,方便您直接使用刚输入的新筛选器来搜索。不勾选时则是置底,方便搜索加了 `$:/tags/Filter` 标签的筛选器条目。
Configs/Appearance/Caption: 样式
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import type { AutocompletePlugin } from '@algolia/autocomplete-js';
import { ITiddlerFields } from 'tiddlywiki';
import { checkIsSearchSystem, checkIsUnderFilter } from '../utils/checkPrefix';
import { cacheSystemTiddlers, searchSystemTitle } from '../utils/configs';
import { searchSystemTitle } from '../utils/configs';
import { debounced } from '../utils/debounce';
import { filterTiddlersAsync } from '../utils/filterTiddlersAsync';
import { lingo } from '../utils/lingo';

/**
* This list won't change during wiki use, so we can only fetch it once.
*/
let cachedTiddlers: ITiddlerFields[] = [];
export const plugin = {
async getSources(parameters) {
if (parameters.query.length === 0) return [];
Expand All @@ -19,10 +15,8 @@ export const plugin = {
sourceId: 'system-title',
async getItems({ query }) {
if (query === '') return [];
if (cachedTiddlers.length === 0 || !cacheSystemTiddlers()) {
cachedTiddlers = await filterTiddlersAsync(`[all[tiddlers+shadows]is[system]search[${query}]]`, { system: true });
}
return cachedTiddlers;
const result = await filterTiddlersAsync(`[all[tiddlers+shadows]is[system]search[${query.substring(1)}]]`, { system: true });
return result;
},
getItemUrl({ item }) {
return item.title;
Expand Down

0 comments on commit 2dcb672

Please sign in to comment.