Skip to content

Commit

Permalink
fix: never search for hostname nor cwd
Browse files Browse the repository at this point in the history
I frequently search for `code ~/my/project/dir`, but I can never find
it, because all commands I've executed inside `~/my/project/dir` seem to
take precedence.

I don't get why someone would ever want to search for cwd or hostname,
but if they would, they could use the annotated keyword syntax for that.
This is a dealbreaker for my workflow.
  • Loading branch information
chelmertz committed Nov 28, 2024
1 parent eedc401 commit 2e7e027
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions client/lib/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,8 @@ func MakeWhereQueryFromSearch(ctx context.Context, db *gorm.DB, query string) (*
}
tx = where(tx, "NOT "+query, v1, v2)
} else {
query, v1, v2, v3, err := parseNonAtomizedToken(token[1:])
if err != nil {
return nil, err
}
tx = tx.Where("NOT "+query, v1, v2, v3)
query, v1 := parseNonAtomizedToken(token[1:])
tx = tx.Where("NOT "+query, v1)
}
} else if containsUnescaped(token, ":") {
query, v1, v2, err := parseAtomizedToken(ctx, token)
Expand All @@ -791,11 +788,8 @@ func MakeWhereQueryFromSearch(ctx context.Context, db *gorm.DB, query string) (*
}
tx = where(tx, query, v1, v2)
} else {
query, v1, v2, v3, err := parseNonAtomizedToken(token)
if err != nil {
return nil, err
}
tx = tx.Where(query, v1, v2, v3)
query, v1 := parseNonAtomizedToken(token)
tx = tx.Where(query, v1)
}
}
return tx, nil
Expand Down Expand Up @@ -845,9 +839,9 @@ func retryingSearch(ctx context.Context, db *gorm.DB, query string, limit, offse
return historyEntries, nil
}

func parseNonAtomizedToken(token string) (string, any, any, any, error) {
func parseNonAtomizedToken(token string) (string, string) {
wildcardedToken := "%" + unescape(token) + "%"
return "(command LIKE ? OR hostname LIKE ? OR current_working_directory LIKE ?)", wildcardedToken, wildcardedToken, wildcardedToken, nil
return "(command LIKE ?)", wildcardedToken
}

func parseAtomizedToken(ctx context.Context, token string) (string, any, any, error) {
Expand Down

0 comments on commit 2e7e027

Please sign in to comment.