Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fzf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
fzf
Commits
f6dd3204
Commit
f6dd3204
authored
9 years ago
by
Giulio Iotti
Browse files
Options
Downloads
Patches
Plain Diff
add support to nil-byte separated input strings, closes #121
parent
443a80f2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core.go
+2
-2
2 additions, 2 deletions
src/core.go
src/options.go
+5
-0
5 additions, 0 deletions
src/options.go
src/reader.go
+15
-21
15 additions, 21 deletions
src/reader.go
with
22 additions
and
23 deletions
src/core.go
+
2
−
2
View file @
f6dd3204
...
...
@@ -113,7 +113,7 @@ func Run(opts *Options) {
// Reader
streamingFilter
:=
opts
.
Filter
!=
nil
&&
!
sort
&&
!
opts
.
Tac
&&
!
opts
.
Sync
if
!
streamingFilter
{
reader
:=
Reader
{
func
(
str
string
)
{
chunkList
.
Push
(
str
)
},
eventBox
}
reader
:=
Reader
{
func
(
str
string
)
{
chunkList
.
Push
(
str
)
},
eventBox
,
opts
.
ReadZero
}
go
reader
.
ReadSource
()
}
...
...
@@ -139,7 +139,7 @@ func Run(opts *Options) {
if
pattern
.
MatchItem
(
item
)
{
fmt
.
Println
(
*
item
.
text
)
}
},
eventBox
}
},
eventBox
,
opts
.
ReadZero
}
reader
.
ReadSource
()
}
else
{
eventBox
.
Unwatch
(
EvtReadNew
)
...
...
This diff is collapsed.
Click to expand it.
src/options.go
+
5
−
0
View file @
f6dd3204
...
...
@@ -50,6 +50,7 @@ const usage = `usage: fzf [options]
-1, --select-1 Automatically select the only match
-0, --exit-0 Exit immediately when there's no match
-f, --filter=STR Filter mode. Do not start interactive finder.
--null Read null-byte separated strings from input
--print-query Print query as the first line
--expect=KEYS Comma-separated list of keys to complete fzf
--sync Synchronous search for multi-staged filtering
...
...
@@ -117,6 +118,7 @@ type Options struct {
Expect
[]
int
Keymap
map
[
int
]
actionType
PrintQuery
bool
ReadZero
bool
Sync
bool
Version
bool
}
...
...
@@ -155,6 +157,7 @@ func defaultOptions() *Options {
Expect
:
[]
int
{},
Keymap
:
defaultKeymap
(),
PrintQuery
:
false
,
ReadZero
:
false
,
Sync
:
false
,
Version
:
false
}
}
...
...
@@ -525,6 +528,8 @@ func parseOptions(opts *Options, allArgs []string) {
opts
.
Exit0
=
true
case
"+0"
,
"--no-exit-0"
:
opts
.
Exit0
=
false
case
"--null"
:
opts
.
ReadZero
=
true
case
"--print-query"
:
opts
.
PrintQuery
=
true
case
"--no-print-query"
:
...
...
This diff is collapsed.
Click to expand it.
src/reader.go
+
15
−
21
View file @
f6dd3204
...
...
@@ -13,6 +13,7 @@ import (
type
Reader
struct
{
pusher
func
(
string
)
eventBox
*
util
.
EventBox
delimNil
bool
}
// ReadSource reads data from the default command or from standard input
...
...
@@ -30,31 +31,24 @@ func (r *Reader) ReadSource() {
}
func
(
r
*
Reader
)
feed
(
src
io
.
Reader
)
{
delim
:=
byte
(
'\n'
)
if
r
.
delimNil
{
delim
=
'\000'
}
reader
:=
bufio
.
NewReader
(
src
)
eof
:=
false
Loop
:
for
!
eof
{
buf
:=
[]
byte
{}
iter
:=
0
// TODO: max size?
for
{
// "ReadLine either returns a non-nil line or it returns an error, never both"
line
,
isPrefix
,
err
:=
reader
.
ReadLine
()
eof
=
err
==
io
.
EOF
if
eof
{
break
}
else
if
err
!=
nil
{
break
Loop
}
iter
++
buf
=
append
(
buf
,
line
...
)
if
!
isPrefix
{
break
for
{
line
,
err
:=
reader
.
ReadString
(
delim
)
if
line
!=
""
{
// "ReadString returns err != nil if and only if the returned data does not end in delim."
if
err
==
nil
{
line
=
line
[
:
len
(
line
)
-
1
]
}
}
if
iter
>
0
{
r
.
pusher
(
string
(
buf
))
r
.
pusher
(
line
)
r
.
eventBox
.
Set
(
EvtReadNew
,
nil
)
}
if
err
!=
nil
{
break
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment