Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

过滤出两条记录,但在Alfred中没有展示 #5

Closed
AllynYonge opened this issue Dec 18, 2017 · 6 comments
Closed

过滤出两条记录,但在Alfred中没有展示 #5

AllynYonge opened this issue Dec 18, 2017 · 6 comments

Comments

@AllynYonge
Copy link

screen shot 2017-12-18 at 11 26 43

@chenzz
Copy link
Contributor

chenzz commented Dec 18, 2017

要解决该问题,建议列出『问题最小可重现条件』

什么是『问题最小可重现条件』,重现该问题的最小条件。

比如,
文件夹中有一个文件,内容是aabb,
用alfred搜索aa时,log有输出,alfred 的list没有输出

这样开发者可以模拟你的环境,不然开发者连你的文件内容是啥都不知道,如何debug呢?

@tianhao
Copy link
Owner

tianhao commented Dec 18, 2017

@AllynYonge 你给出的信息没法重现
1.请使用最新版;
2.检查你的配置;
3.如1,2都没问题,Log 改成 『All information』,贴出你的日志

@AllynYonge
Copy link
Author

使用的是最新的版本

我搜寻的关键字为git,Alfred显示结果如下:
image

这是Debug的日志:
[2017-12-18 14:03:59][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:

# 代码拼装的bash命令如下:
ls -t *.md| xargs grep -ile 'git' | awk -F':' '{print $1}' | uniq  | awk '{system("egrep -ioe \"git\" <<< `head -1 "$1 "`|wc -l | xargs echo "$1)}' | sort -rk 2 | awk '{print $1}'  | head -20 

output_files的输入结果如下:

{"items":[
{
"type": "file",
"title": "# git_reflog",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468845222.md"
}
,{
"type": "file",
"title": "## git_diff",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468845190.md"
}
,{
"type": "file",
"title": "# git_rebase",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468845154.md"
}
,{
"type": "file",
"title": "# git过滤规则",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468845081.md"
}
,{
"type": "file",
"title": "# Git_reset",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468845015.md"
}
,{
"type": "file",
"title": "# git_blame",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468844979.md"
}
,{
"type": "file",
"title": "## git的log命令",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468844942.md"
}
,{
"type": "file",
"title": "# Git中文件的4种状态",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468844840.md"
}
,{
"type": "file",
"title": "# Git常用命令总结",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468844803.md"
}
,{
"type": "file",
"title": "# 搭建hexo + github pages + next主题",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15125399987430.md"
}
,{
"type": "file",
"title": "# Android常用API",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15135678546725.md"
}
,{
"type": "file",
"title": "# 建造者模式",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15132378779170.md"
}
,{
"type": "file",
"title": "# 模板设计模式",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15132378779074.md"
}
,{
"type": "file",
"title": "# 编译时注解处理",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15132352795991.md"
}
,{
"type": "file",
"title": "# \^和~的区别",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468845114.md"
}
,{
"type": "file",
"title": "# 暂存文件的部分改动",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468845049.md"
}
,{
"type": "file",
"title": "# Cherry_Pick",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468844908.md"
}
,{
"type": "file",
"title": "# Stash未提交的更改",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468844874.md"
}
,{
"type": "file",
"title": "# How to Install MySQL on CentOS 7",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131445665600.md"
}
,{
"type": "file",
"title": "# grep正则表达式",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131442736340.md"
}
]}

我自己在终端运行上面拼装的命令结果如下:
image

@tianhao
Copy link
Owner

tianhao commented Dec 18, 2017

原因在这里:

,{
"type": "file",
"title": "# \^和~的区别",
"arg": "/Users/AllynYonge/Library/Containers/com.coderforart.MWeb/Data/Documents/mainlib/docs/15131468845114.md"
}

# \^和~的区别 中的 "\" 需要转译为 "\\"

search.sh 118 行改为:

        h="$(head -1 "${i}"| sed 's/\\/\\\\/g' | sed 's/"/\\"/g')"

@tianhao tianhao reopened this Dec 18, 2017
@tianhao
Copy link
Owner

tianhao commented Dec 18, 2017

执行这个提交既然 close 了这个issue

git commit -m "fix https://github.com/tianhao/alfred-mweb-workflow/issues/5"

@AllynYonge 你再捡查一下

@AllynYonge
Copy link
Author

好了,已经解决,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants