summaryrefslogtreecommitdiffstats
path: root/src/terminal_test.go
AgeCommit message (Collapse)Author
2024-05-07Refactor the code to remove global variablesJunegunn Choi
2024-04-28Fix escaping for cmd.exeJunegunn Choi
Close #3651 Close #2609
2024-04-27Add --with-shell for shelling out with different command and flags (#3746)Junegunn Choi
Close #3732
2023-12-28Add {fzf:prompt} placeholder expressionJunegunn Choi
Close #3354
2023-12-26{fzf:query} should trigger preview updateJunegunn Choi
fzf --preview 'echo {fzf:query}' fzf --preview 'echo {q}'
2023-12-26Add 'transform' action to conditionally perform a series of actionsJunegunn Choi
'transform' action runs an external command that prints a series of actions to perform. # Disallow selecting an empty line echo -e "1. Hello\n2. Goodbye\n\n3. Exit" | fzf --reverse --header 'Select one' \ --bind 'enter:transform:[[ -n {} ]] && echo accept || echo "change-header:Invalid selection"' # Move cursor past the empty line echo -e "1. Hello\n2. Goodbye\n\n3. Exit" | fzf --reverse --header 'Select one' \ --bind 'enter:transform:[[ -n {} ]] && echo accept || echo "change-header:Invalid selection"' \ --bind 'focus:transform:[[ -n {} ]] && exit; [[ {fzf:action} =~ up$ ]] && echo up || echo down' Close #3368 Close #2980
2022-08-12Reformat comments adhere to gofmtJunegunn Choi
2021-11-02Document escaping and expanding of quotes on WindowsVlastimil Ovčáčík
Parsers included: - go parser (well, this is easily dealt with using `` strings) - win32 (shell-api) parser - powershell parser (for powershell commands) - powershell parsing rules for calling native commands - internal parsers of select regex applications (like grep)
2021-11-02Test escaping of powershell commands on WindowsVlastimil Ovčáčík
2021-10-15Add more tests of placeholder flags and simplify its logic (#2624)Vlastimil Ovčáčík
* [tests] Test fzf's placeholders and escaping on practical commands This tests some reasonable commands in fzf's templates (for commands, previews, rebinds etc.), how are those commands escaped (backslashes, double quotes), and documents if the output is executable in cmd.exe. Both on Unix and Windows. * [tests] Add testing of placeholder parsing and matching Adds tests and bit of docs for the curly brackets placeholders in fzf's template strings. Also tests the "placeholder" regex. * [tests] Add more test cases of replacing placeholders focused on flags Replacing placeholders in templates is already tested, this adds tests that focus more on the parameters of placeholders - e.g. flags, token ranges. There is at least one test for each flag, not all combinations are tested though. * [refactoring] Split OS-specific function quoteEntry() to corresponding source file This is minor refactoring, and also the function's test was made crossplatform. * [refactoring] Simplify replacePlaceholder function Should be equivalent to the original, but has simpler structure.
2021-09-24Change the tests to run on Windows (#2615)Vlastimil Ovčáčík
Most of the "expected" strings in terminal.go test were changed to "text/template" values. Quotes in those string were parametrized in the templates. Two functions handling templates were added for convenience. Templates has the advantage of: - parametrize repetitive strings inside "expected" values - inner and outer quotes were parametrized in templates - long and confusing test values are more readable - templates can be localized for other operating systems
2019-11-05Improvements to code quality and readability (#1737)Alexandr
* Remove 1 unused field and 3 unused functions unused elements fount by running golangci-lint run --disable-all --enable unused src/result.go:19:2: field `index` is unused (unused) index int32 ^ src/tui/light.go:716:23: func `(*LightWindow).stderr` is unused (unused) func (w *LightWindow) stderr(str string) { ^ src/terminal.go:1015:6: func `numLinesMax` is unused (unused) func numLinesMax(str string, max int) int { ^ src/tui/tui.go:167:20: func `ColorPair.is24` is unused (unused) func (p ColorPair) is24() bool { ^ * Address warnings from "gosimple" linter src/options.go:389:83: S1003: should use strings.Contains(str, ",,,") instead (gosimple) if str == "," || strings.HasPrefix(str, ",,") || strings.HasSuffix(str, ",,") || strings.Index(str, ",,,") >= 0 { ^ src/options.go:630:18: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple) executeRegexp = regexp.MustCompile( ^ src/terminal.go:29:16: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple) placeholder = regexp.MustCompile("\\\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\\+?f?nf?})") ^ src/terminal_test.go:92:10: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple) regex = regexp.MustCompile("\\w+") ^ * Address warnings from "staticcheck" linter src/algo/algo.go:374:2: SA4006: this value of `offset32` is never used (staticcheck) offset32, T := alloc32(offset32, slab, N) ^ src/algo/algo.go:456:2: SA4006: this value of `offset16` is never used (staticcheck) offset16, C := alloc16(offset16, slab, width*M) ^ src/tui/tui.go:119:2: SA9004: only the first constant in this group has an explicit type (staticcheck) colUndefined Color = -2 ^
2019-10-27Add 'f' flag for placeholder expression (#1733)Simon Fraser
If present the contents of the selection will be placed in a temporary file, and the filename will be placed into the string instead.
2018-03-30Implement flag for preserving whitespace around field (#1242)ZDNoFYVe
2017-10-14Fix ExecCommandWith for cmd.exe in Windows (#1072)Jan Edmund Lazo
Close #1018 Run the command as is in cmd.exe with no parsing and escaping. Explicity set cmd.SysProcAttr so execCommand does not escape the command. Technically, the command should be escaped with ^ for special characters, including ". This allows cmd.exe commands to be chained together. See https://github.com/neovim/neovim/pull/7343#issuecomment-333350201 This commit also updates quoteEntry to use strings.Replace instead of strconv.Quote which escapes more than \ and ".
2017-07-21Further reduce unnecessary rune array conversionJunegunn Choi
I was too quick to release 0.16.9, this commit makes --ansi processing even faster.
2017-01-27Add execute-silent actionJunegunn Choi
Close #823
2016-10-03Support field index expressions in preview and execute actionJunegunn Choi
Also close #679. The placeholder for the current query is {q}.