Add change-with-nth action to dynamically change --with-nth (#4691)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by GitHub · parent 5887edc · Browse files · 9 files·+548 added−181 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+548 added−181 removed
- tests:+185 added−0 removed
- other:+363 added−181 removed
Provenance
- Commit
3cfee28- Tree
13e735e- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
5887edc
9 files changed+548 added−181 removed
modified:man/man1/fzf.1+12 added
132 unmodified lines133 134 # Use template to rearrange fields135 echo foo,bar,baz | fzf --delimiter , --with-nth '{n},{1},{3},{2},{1..2}'136 .RE137+.RS138+139+\fBchange\-with\-nth\fR action is only available when \fB\-\-with\-nth\fR is set.140+When \fB\-\-with\-nth\fR is used, fzf retains the original input lines in memory141+so they can be re\-transformed on the fly (e.g. \fB\-\-with\-nth ..\fR to keep142+the original presentation). This increases memory usage, so only use143+\fB\-\-with\-nth\fR when you actually need field transformation.144+.RE145 .TP146 .BI "\-\-accept\-nth=" "N[,..] or TEMPLATE"147 Define which fields to print on accept. The last delimiter is stripped from the148 output. For advanced transformation, you can provide a template containing1256 unmodified lines1405 .BR FZF_INPUT_STATE " Current input state (enabled, disabled, hidden)"1406 .br1407 .BR FZF_NTH " Current \-\-nth option"1408 .br1409+.BR FZF_WITH_NTH " Current \-\-with\-nth option"1410+.br1411 .BR FZF_PROMPT " Prompt string"1412 .br1413 .BR FZF_GHOST " Ghost string"1414 .br482 unmodified lines1897 \fBchange\-list\-label(...)\fR (change \fB\-\-list\-label\fR to the given string)1898 \fBchange\-multi\fR (enable multi-select mode with no limit)1899 \fBchange\-multi(...)\fR (enable multi-select mode with a limit or disable it with 0)1900 \fBchange\-nth(...)\fR (change \fB\-\-nth\fR option; rotate through the multiple options separated by '|')1901+ \fBchange\-with\-nth(...)\fR (change \fB\-\-with\-nth\fR option; rotate through the multiple options separated by '|')1902 \fBchange\-pointer(...)\fR (change \fB\-\-pointer\fR option)1903 \fBchange\-preview(...)\fR (change \fB\-\-preview\fR option)1904 \fBchange\-preview\-label(...)\fR (change \fB\-\-preview\-label\fR to the given string)1905 \fBchange\-preview\-window(...)\fR (change \fB\-\-preview\-window\fR option; rotate through the multiple option sets separated by '|')97 unmodified lines2003 \fBtransform\-header\-label(...)\fR (transform header label using an external command)2004 \fBtransform\-input\-label(...)\fR (transform input label using an external command)2005 \fBtransform\-list\-label(...)\fR (transform list label using an external command)2006 \fBtransform\-nth(...)\fR (transform nth using an external command)2007+ \fBtransform\-with\-nth(...)\fR (transform with-nth using an external command)2008 \fBtransform\-pointer(...)\fR (transform pointer using an external command)2009 \fBtransform\-preview\-label(...)\fR (transform preview label using an external command)2010 \fBtransform\-prompt(...)\fR (transform prompt string using an external command)2011 \fBtransform\-query(...)\fR (transform query string using an external command)209 unmodified linesmodified:src/actiontype_string.go+150 added-147 removed
36 unmodified lines37 _ = x[actChangeInputLabel-26]38 _ = x[actChangeListLabel-27]39 _ = x[actChangeMulti-28]40 _ = x[actChangeNth-29]41- _ = x[actChangePointer-30]42- _ = x[actChangePreview-31]43- _ = x[actChangePreviewLabel-32]44- _ = x[actChangePreviewWindow-33]45- _ = x[actChangePrompt-34]46- _ = x[actChangeQuery-35]47- _ = x[actClearScreen-36]48- _ = x[actClearQuery-37]49- _ = x[actClearSelection-38]50- _ = x[actClose-39]51- _ = x[actDeleteChar-40]52- _ = x[actDeleteCharEof-41]53- _ = x[actEndOfLine-42]54- _ = x[actFatal-43]55- _ = x[actForwardChar-44]56- _ = x[actForwardWord-45]57- _ = x[actForwardSubWord-46]58- _ = x[actKillLine-47]59- _ = x[actKillWord-48]60- _ = x[actKillSubWord-49]61- _ = x[actUnixLineDiscard-50]62- _ = x[actUnixWordRubout-51]63- _ = x[actYank-52]64- _ = x[actBackwardKillWord-53]65- _ = x[actBackwardKillSubWord-54]66- _ = x[actSelectAll-55]67- _ = x[actDeselectAll-56]68- _ = x[actToggle-57]69- _ = x[actToggleSearch-58]70- _ = x[actToggleAll-59]71- _ = x[actToggleDown-60]72- _ = x[actToggleUp-61]73- _ = x[actToggleIn-62]74- _ = x[actToggleOut-63]75- _ = x[actToggleTrack-64]76- _ = x[actToggleTrackCurrent-65]77- _ = x[actToggleHeader-66]78- _ = x[actToggleWrap-67]79- _ = x[actToggleWrapWord-68]80- _ = x[actToggleMultiLine-69]81- _ = x[actToggleHscroll-70]82- _ = x[actToggleRaw-71]83- _ = x[actEnableRaw-72]84- _ = x[actDisableRaw-73]85- _ = x[actTrackCurrent-74]86- _ = x[actToggleInput-75]87- _ = x[actHideInput-76]88- _ = x[actShowInput-77]89- _ = x[actUntrackCurrent-78]90- _ = x[actDown-79]91- _ = x[actDownMatch-80]92- _ = x[actUp-81]93- _ = x[actUpMatch-82]94- _ = x[actPageUp-83]95- _ = x[actPageDown-84]96- _ = x[actPosition-85]97- _ = x[actHalfPageUp-86]98- _ = x[actHalfPageDown-87]99- _ = x[actOffsetUp-88]100- _ = x[actOffsetDown-89]101- _ = x[actOffsetMiddle-90]102- _ = x[actJump-91]103- _ = x[actJumpAccept-92]104- _ = x[actPrintQuery-93]105- _ = x[actRefreshPreview-94]106- _ = x[actReplaceQuery-95]107- _ = x[actToggleSort-96]108- _ = x[actShowPreview-97]109- _ = x[actHidePreview-98]110- _ = x[actTogglePreview-99]111- _ = x[actTogglePreviewWrap-100]112- _ = x[actTogglePreviewWrapWord-101]113- _ = x[actTransform-102]114- _ = x[actTransformBorderLabel-103]115- _ = x[actTransformGhost-104]116- _ = x[actTransformHeader-105]117- _ = x[actTransformHeaderLines-106]118- _ = x[actTransformFooter-107]119- _ = x[actTransformHeaderLabel-108]120- _ = x[actTransformFooterLabel-109]121- _ = x[actTransformInputLabel-110]122- _ = x[actTransformListLabel-111]123- _ = x[actTransformNth-112]124- _ = x[actTransformPointer-113]125- _ = x[actTransformPreviewLabel-114]126- _ = x[actTransformPrompt-115]127- _ = x[actTransformQuery-116]128- _ = x[actTransformSearch-117]129- _ = x[actTrigger-118]130- _ = x[actBgTransform-119]131- _ = x[actBgTransformBorderLabel-120]132- _ = x[actBgTransformGhost-121]133- _ = x[actBgTransformHeader-122]134- _ = x[actBgTransformHeaderLines-123]135- _ = x[actBgTransformFooter-124]136- _ = x[actBgTransformHeaderLabel-125]137- _ = x[actBgTransformFooterLabel-126]138- _ = x[actBgTransformInputLabel-127]139- _ = x[actBgTransformListLabel-128]140- _ = x[actBgTransformNth-129]141- _ = x[actBgTransformPointer-130]142- _ = x[actBgTransformPreviewLabel-131]143- _ = x[actBgTransformPrompt-132]144- _ = x[actBgTransformQuery-133]145- _ = x[actBgTransformSearch-134]146- _ = x[actBgCancel-135]147- _ = x[actSearch-136]148- _ = x[actPreview-137]149- _ = x[actPreviewTop-138]150- _ = x[actPreviewBottom-139]151- _ = x[actPreviewUp-140]152- _ = x[actPreviewDown-141]153- _ = x[actPreviewPageUp-142]154- _ = x[actPreviewPageDown-143]155- _ = x[actPreviewHalfPageUp-144]156- _ = x[actPreviewHalfPageDown-145]157- _ = x[actPrevHistory-146]158- _ = x[actPrevSelected-147]159- _ = x[actPrint-148]160- _ = x[actPut-149]161- _ = x[actNextHistory-150]162- _ = x[actNextSelected-151]163- _ = x[actExecute-152]164- _ = x[actExecuteSilent-153]165- _ = x[actExecuteMulti-154]166- _ = x[actSigStop-155]167- _ = x[actBest-156]168- _ = x[actFirst-157]169- _ = x[actLast-158]170- _ = x[actReload-159]171- _ = x[actReloadSync-160]172- _ = x[actDisableSearch-161]173- _ = x[actEnableSearch-162]174- _ = x[actSelect-163]175- _ = x[actDeselect-164]176- _ = x[actUnbind-165]177- _ = x[actRebind-166]178- _ = x[actToggleBind-167]179- _ = x[actBecome-168]180- _ = x[actShowHeader-169]181- _ = x[actHideHeader-170]182- _ = x[actBell-171]183- _ = x[actExclude-172]184- _ = x[actExcludeMulti-173]185- _ = x[actAsync-174]41+ _ = x[actChangeWithNth-30]42+ _ = x[actChangePointer-31]43+ _ = x[actChangePreview-32]44+ _ = x[actChangePreviewLabel-33]45+ _ = x[actChangePreviewWindow-34]46+ _ = x[actChangePrompt-35]47+ _ = x[actChangeQuery-36]48+ _ = x[actClearScreen-37]49+ _ = x[actClearQuery-38]50+ _ = x[actClearSelection-39]51+ _ = x[actClose-40]52+ _ = x[actDeleteChar-41]53+ _ = x[actDeleteCharEof-42]54+ _ = x[actEndOfLine-43]55+ _ = x[actFatal-44]56+ _ = x[actForwardChar-45]57+ _ = x[actForwardWord-46]58+ _ = x[actForwardSubWord-47]59+ _ = x[actKillLine-48]60+ _ = x[actKillWord-49]61+ _ = x[actKillSubWord-50]62+ _ = x[actUnixLineDiscard-51]63+ _ = x[actUnixWordRubout-52]64+ _ = x[actYank-53]65+ _ = x[actBackwardKillWord-54]66+ _ = x[actBackwardKillSubWord-55]67+ _ = x[actSelectAll-56]68+ _ = x[actDeselectAll-57]69+ _ = x[actToggle-58]70+ _ = x[actToggleSearch-59]71+ _ = x[actToggleAll-60]72+ _ = x[actToggleDown-61]73+ _ = x[actToggleUp-62]74+ _ = x[actToggleIn-63]75+ _ = x[actToggleOut-64]76+ _ = x[actToggleTrack-65]77+ _ = x[actToggleTrackCurrent-66]78+ _ = x[actToggleHeader-67]79+ _ = x[actToggleWrap-68]80+ _ = x[actToggleWrapWord-69]81+ _ = x[actToggleMultiLine-70]82+ _ = x[actToggleHscroll-71]83+ _ = x[actToggleRaw-72]84+ _ = x[actEnableRaw-73]85+ _ = x[actDisableRaw-74]86+ _ = x[actTrackCurrent-75]87+ _ = x[actToggleInput-76]88+ _ = x[actHideInput-77]89+ _ = x[actShowInput-78]90+ _ = x[actUntrackCurrent-79]91+ _ = x[actDown-80]92+ _ = x[actDownMatch-81]93+ _ = x[actUp-82]94+ _ = x[actUpMatch-83]95+ _ = x[actPageUp-84]96+ _ = x[actPageDown-85]97+ _ = x[actPosition-86]98+ _ = x[actHalfPageUp-87]99+ _ = x[actHalfPageDown-88]100+ _ = x[actOffsetUp-89]101+ _ = x[actOffsetDown-90]102+ _ = x[actOffsetMiddle-91]103+ _ = x[actJump-92]104+ _ = x[actJumpAccept-93]105+ _ = x[actPrintQuery-94]106+ _ = x[actRefreshPreview-95]107+ _ = x[actReplaceQuery-96]108+ _ = x[actToggleSort-97]109+ _ = x[actShowPreview-98]110+ _ = x[actHidePreview-99]111+ _ = x[actTogglePreview-100]112+ _ = x[actTogglePreviewWrap-101]113+ _ = x[actTogglePreviewWrapWord-102]114+ _ = x[actTransform-103]115+ _ = x[actTransformBorderLabel-104]116+ _ = x[actTransformGhost-105]117+ _ = x[actTransformHeader-106]118+ _ = x[actTransformHeaderLines-107]119+ _ = x[actTransformFooter-108]120+ _ = x[actTransformHeaderLabel-109]121+ _ = x[actTransformFooterLabel-110]122+ _ = x[actTransformInputLabel-111]123+ _ = x[actTransformListLabel-112]124+ _ = x[actTransformNth-113]125+ _ = x[actTransformWithNth-114]126+ _ = x[actTransformPointer-115]127+ _ = x[actTransformPreviewLabel-116]128+ _ = x[actTransformPrompt-117]129+ _ = x[actTransformQuery-118]130+ _ = x[actTransformSearch-119]131+ _ = x[actTrigger-120]132+ _ = x[actBgTransform-121]133+ _ = x[actBgTransformBorderLabel-122]134+ _ = x[actBgTransformGhost-123]135+ _ = x[actBgTransformHeader-124]136+ _ = x[actBgTransformHeaderLines-125]137+ _ = x[actBgTransformFooter-126]138+ _ = x[actBgTransformHeaderLabel-127]139+ _ = x[actBgTransformFooterLabel-128]140+ _ = x[actBgTransformInputLabel-129]141+ _ = x[actBgTransformListLabel-130]142+ _ = x[actBgTransformNth-131]143+ _ = x[actBgTransformWithNth-132]144+ _ = x[actBgTransformPointer-133]145+ _ = x[actBgTransformPreviewLabel-134]146+ _ = x[actBgTransformPrompt-135]147+ _ = x[actBgTransformQuery-136]148+ _ = x[actBgTransformSearch-137]149+ _ = x[actBgCancel-138]150+ _ = x[actSearch-139]151+ _ = x[actPreview-140]152+ _ = x[actPreviewTop-141]153+ _ = x[actPreviewBottom-142]154+ _ = x[actPreviewUp-143]155+ _ = x[actPreviewDown-144]156+ _ = x[actPreviewPageUp-145]157+ _ = x[actPreviewPageDown-146]158+ _ = x[actPreviewHalfPageUp-147]159+ _ = x[actPreviewHalfPageDown-148]160+ _ = x[actPrevHistory-149]161+ _ = x[actPrevSelected-150]162+ _ = x[actPrint-151]163+ _ = x[actPut-152]164+ _ = x[actNextHistory-153]165+ _ = x[actNextSelected-154]166+ _ = x[actExecute-155]167+ _ = x[actExecuteSilent-156]168+ _ = x[actExecuteMulti-157]169+ _ = x[actSigStop-158]170+ _ = x[actBest-159]171+ _ = x[actFirst-160]172+ _ = x[actLast-161]173+ _ = x[actReload-162]174+ _ = x[actReloadSync-163]175+ _ = x[actDisableSearch-164]176+ _ = x[actEnableSearch-165]177+ _ = x[actSelect-166]178+ _ = x[actDeselect-167]179+ _ = x[actUnbind-168]180+ _ = x[actRebind-169]181+ _ = x[actToggleBind-170]182+ _ = x[actBecome-171]183+ _ = x[actShowHeader-172]184+ _ = x[actHideHeader-173]185+ _ = x[actBell-174]186+ _ = x[actExclude-175]187+ _ = x[actExcludeMulti-176]188+ _ = x[actAsync-177]189 }190 188-const _actionType_name = "actIgnoreactStartactClickactInvalidactBracketedPasteBeginactBracketedPasteEndactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactBackwardSubWordactCancelactChangeBorderLabelactChangeGhostactChangeHeaderactChangeHeaderLinesactChangeFooteractChangeHeaderLabelactChangeFooterLabelactChangeInputLabelactChangeListLabelactChangeMultiactChangeNthactChangePointeractChangePreviewactChangePreviewLabelactChangePreviewWindowactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactForwardSubWordactKillLineactKillWordactKillSubWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactBackwardKillSubWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleWrapWordactToggleMultiLineactToggleHscrollactToggleRawactEnableRawactDisableRawactTrackCurrentactToggleInputactHideInputactShowInputactUntrackCurrentactDownactDownMatchactUpactUpMatchactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTogglePreviewWrapWordactTransformactTransformBorderLabelactTransformGhostactTransformHeaderactTransformHeaderLinesactTransformFooteractTransformHeaderLabelactTransformFooterLabelactTransformInputLabelactTransformListLabelactTransformNthactTransformPointeractTransformPreviewLabelactTransformPromptactTransformQueryactTransformSearchactTriggeractBgTransformactBgTransformBorderLabelactBgTransformGhostactBgTransformHeaderactBgTransformHeaderLinesactBgTransformFooteractBgTransformHeaderLabelactBgTransformFooterLabelactBgTransformInputLabelactBgTransformListLabelactBgTransformNthactBgTransformPointeractBgTransformPreviewLabelactBgTransformPromptactBgTransformQueryactBgTransformSearchactBgCancelactSearchactPreviewactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactBestactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactToggleBindactBecomeactShowHeaderactHideHeaderactBellactExcludeactExcludeMultiactAsync"191+const _actionType_name = "actIgnoreactStartactClickactInvalidactBracketedPasteBeginactBracketedPasteEndactCharactMouseactBeginningOfLineactAbortactAcceptactAcceptNonEmptyactAcceptOrPrintQueryactBackwardCharactBackwardDeleteCharactBackwardDeleteCharEofactBackwardWordactBackwardSubWordactCancelactChangeBorderLabelactChangeGhostactChangeHeaderactChangeHeaderLinesactChangeFooteractChangeHeaderLabelactChangeFooterLabelactChangeInputLabelactChangeListLabelactChangeMultiactChangeNthactChangeWithNthactChangePointeractChangePreviewactChangePreviewLabelactChangePreviewWindowactChangePromptactChangeQueryactClearScreenactClearQueryactClearSelectionactCloseactDeleteCharactDeleteCharEofactEndOfLineactFatalactForwardCharactForwardWordactForwardSubWordactKillLineactKillWordactKillSubWordactUnixLineDiscardactUnixWordRuboutactYankactBackwardKillWordactBackwardKillSubWordactSelectAllactDeselectAllactToggleactToggleSearchactToggleAllactToggleDownactToggleUpactToggleInactToggleOutactToggleTrackactToggleTrackCurrentactToggleHeaderactToggleWrapactToggleWrapWordactToggleMultiLineactToggleHscrollactToggleRawactEnableRawactDisableRawactTrackCurrentactToggleInputactHideInputactShowInputactUntrackCurrentactDownactDownMatchactUpactUpMatchactPageUpactPageDownactPositionactHalfPageUpactHalfPageDownactOffsetUpactOffsetDownactOffsetMiddleactJumpactJumpAcceptactPrintQueryactRefreshPreviewactReplaceQueryactToggleSortactShowPreviewactHidePreviewactTogglePreviewactTogglePreviewWrapactTogglePreviewWrapWordactTransformactTransformBorderLabelactTransformGhostactTransformHeaderactTransformHeaderLinesactTransformFooteractTransformHeaderLabelactTransformFooterLabelactTransformInputLabelactTransformListLabelactTransformNthactTransformWithNthactTransformPointeractTransformPreviewLabelactTransformPromptactTransformQueryactTransformSearchactTriggeractBgTransformactBgTransformBorderLabelactBgTransformGhostactBgTransformHeaderactBgTransformHeaderLinesactBgTransformFooteractBgTransformHeaderLabelactBgTransformFooterLabelactBgTransformInputLabelactBgTransformListLabelactBgTransformNthactBgTransformWithNthactBgTransformPointeractBgTransformPreviewLabelactBgTransformPromptactBgTransformQueryactBgTransformSearchactBgCancelactSearchactPreviewactPreviewTopactPreviewBottomactPreviewUpactPreviewDownactPreviewPageUpactPreviewPageDownactPreviewHalfPageUpactPreviewHalfPageDownactPrevHistoryactPrevSelectedactPrintactPutactNextHistoryactNextSelectedactExecuteactExecuteSilentactExecuteMultiactSigStopactBestactFirstactLastactReloadactReloadSyncactDisableSearchactEnableSearchactSelectactDeselectactUnbindactRebindactToggleBindactBecomeactShowHeaderactHideHeaderactBellactExcludeactExcludeMultiactAsync"192 190-var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 57, 77, 84, 92, 110, 118, 127, 144, 165, 180, 201, 225, 240, 258, 267, 287, 301, 316, 336, 351, 371, 391, 410, 428, 442, 454, 470, 486, 507, 529, 544, 558, 572, 585, 602, 610, 623, 639, 651, 659, 673, 687, 704, 715, 726, 740, 758, 775, 782, 801, 823, 835, 849, 858, 873, 885, 898, 909, 920, 932, 946, 967, 982, 995, 1012, 1030, 1046, 1058, 1070, 1083, 1098, 1112, 1124, 1136, 1153, 1160, 1172, 1177, 1187, 1196, 1207, 1218, 1231, 1246, 1257, 1270, 1285, 1292, 1305, 1318, 1335, 1350, 1363, 1377, 1391, 1407, 1427, 1451, 1463, 1486, 1503, 1521, 1544, 1562, 1585, 1608, 1630, 1651, 1666, 1685, 1709, 1727, 1744, 1762, 1772, 1786, 1811, 1830, 1850, 1875, 1895, 1920, 1945, 1969, 1992, 2009, 2030, 2056, 2076, 2095, 2115, 2126, 2135, 2145, 2158, 2174, 2186, 2200, 2216, 2234, 2254, 2276, 2290, 2305, 2313, 2319, 2333, 2348, 2358, 2374, 2389, 2399, 2406, 2414, 2421, 2430, 2443, 2459, 2474, 2483, 2494, 2503, 2512, 2525, 2534, 2547, 2560, 2567, 2577, 2592, 2600}193+var _actionType_index = [...]uint16{0, 9, 17, 25, 35, 57, 77, 84, 92, 110, 118, 127, 144, 165, 180, 201, 225, 240, 258, 267, 287, 301, 316, 336, 351, 371, 391, 410, 428, 442, 454, 470, 486, 502, 523, 545, 560, 574, 588, 601, 618, 626, 639, 655, 667, 675, 689, 703, 720, 731, 742, 756, 774, 791, 798, 817, 839, 851, 865, 874, 889, 901, 914, 925, 936, 948, 962, 983, 998, 1011, 1028, 1046, 1062, 1074, 1086, 1099, 1114, 1128, 1140, 1152, 1169, 1176, 1188, 1193, 1203, 1212, 1223, 1234, 1247, 1262, 1273, 1286, 1301, 1308, 1321, 1334, 1351, 1366, 1379, 1393, 1407, 1423, 1443, 1467, 1479, 1502, 1519, 1537, 1560, 1578, 1601, 1624, 1646, 1667, 1682, 1701, 1720, 1744, 1762, 1779, 1797, 1807, 1821, 1846, 1865, 1885, 1910, 1930, 1955, 1980, 2004, 2027, 2044, 2065, 2086, 2112, 2132, 2151, 2171, 2182, 2191, 2201, 2214, 2230, 2242, 2256, 2272, 2290, 2310, 2332, 2346, 2361, 2369, 2375, 2389, 2404, 2414, 2430, 2445, 2455, 2462, 2470, 2477, 2486, 2499, 2515, 2530, 2539, 2550, 2559, 2568, 2581, 2590, 2603, 2616, 2623, 2633, 2648, 2656}194 195 func (i actionType) String() string {196 if i < 0 || i >= actionType(len(_actionType_index)-1) {197 return "actionType(" + strconv.FormatInt(int64(i), 10) + ")"3 unmodified linesmodified:src/chunklist.go+15 added
97 unmodified lines98 cl.chunks = nil99 cl.mutex.Unlock()100 }101 102+// ForEachItem iterates all items and applies fn to each one.103+// The done callback runs under the lock to safely update shared state.104+func (cl *ChunkList) ForEachItem(fn func(*Item), done func()) {105+ cl.mutex.Lock()106+ for _, chunk := range cl.chunks {107+ for i := 0; i < chunk.count; i++ {108+ fn(&chunk.items[i])109+ }110+ }111+ if done != nil {112+ done()113+ }114+ cl.mutex.Unlock()115+}116+117 // Snapshot returns immutable snapshot of the ChunkList118 func (cl *ChunkList) Snapshot(tail int) ([]*Chunk, int, bool) {119 cl.mutex.Lock()120 50 unmodified linesmodified:src/core.go+72 added-30 removed
111 unmodified lines112 // Chunk list113 cache := NewChunkCache()114 var chunkList *ChunkList115 var itemIndex int32116+ // transformItem applies with-nth transformation to an item's raw data.117+ // It handles ANSI token propagation using prevLineAnsiState for cross-line continuity.118+ transformItem := func(item *Item, data []byte, transformer func([]Token, int32) string, index int32) {119+ tokens := Tokenize(byteString(data), opts.Delimiter)120+ if opts.Ansi && len(tokens) > 1 {121+ var ansiState *ansiState122+ if prevLineAnsiState != nil {123+ ansiStateDup := *prevLineAnsiState124+ ansiState = &ansiStateDup125+ }126+ for _, token := range tokens {127+ prevAnsiState := ansiState128+ _, _, ansiState = extractColor(token.text.ToString(), ansiState, nil)129+ if prevAnsiState != nil {130+ token.text.Prepend("\x1b[m" + prevAnsiState.ToString())131+ } else {132+ token.text.Prepend("\x1b[m")133+ }134+ }135+ }136+ transformed := transformer(tokens, index)137+ item.text, item.colors = ansiProcessor(stringBytes(transformed))138+139+ // We should not trim trailing whitespaces with background colors140+ var maxColorOffset int32141+ if item.colors != nil {142+ for _, ansi := range *item.colors {143+ if ansi.color.bg >= 0 {144+ maxColorOffset = max(maxColorOffset, ansi.offset[1])145+ }146+ }147+ }148+ item.text.TrimTrailingWhitespaces(int(maxColorOffset))149+ }150+151+ var nthTransformer func([]Token, int32) string152 if opts.WithNth == nil {153 chunkList = NewChunkList(cache, func(item *Item, data []byte) bool {154 item.text, item.colors = ansiProcessor(data)155 item.text.Index = itemIndex156 itemIndex++157 return true158 })159 } else {124- nthTransformer := opts.WithNth(opts.Delimiter)160+ nthTransformer = opts.WithNth(opts.Delimiter)161 chunkList = NewChunkList(cache, func(item *Item, data []byte) bool {126- tokens := Tokenize(byteString(data), opts.Delimiter)127- if opts.Ansi && len(tokens) > 1 {128- var ansiState *ansiState129- if prevLineAnsiState != nil {130- ansiStateDup := *prevLineAnsiState131- ansiState = &ansiStateDup132- }133- for _, token := range tokens {134- prevAnsiState := ansiState135- _, _, ansiState = extractColor(token.text.ToString(), ansiState, nil)136- if prevAnsiState != nil {137- token.text.Prepend("\x1b[m" + prevAnsiState.ToString())138- } else {139- token.text.Prepend("\x1b[m")140- }141- }162+ if nthTransformer == nil {163+ item.text, item.colors = ansiProcessor(data)164+ } else {165+ transformItem(item, data, nthTransformer, itemIndex)166 }143- transformed := nthTransformer(tokens, itemIndex)144- item.text, item.colors = ansiProcessor(stringBytes(transformed))145-146- // We should not trim trailing whitespaces with background colors147- var maxColorOffset int32148- if item.colors != nil {149- for _, ansi := range *item.colors {150- if ansi.color.bg >= 0 {151- maxColorOffset = max(maxColorOffset, ansi.offset[1])152- }153- }154- }155- item.text.TrimTrailingWhitespaces(int(maxColorOffset))167 item.text.Index = itemIndex168 item.origText = &data169 itemIndex++170 return true300 unmodified lines471 var command *commandSpec472 var environ []string473 var changed bool474 headerLinesChanged := false475+ withNthChanged := false476 switch val := value.(type) {477 case searchRequest:478 sort = val.sort479 command = val.command18 unmodified lines498 headerUpdated = false499 headerLinesChanged = true500 bump = true501 }502+ if val.withNth != nil {503+ newTransformer := val.withNth.fn504+ // Cancel any in-flight scan and block the terminal from reading505+ // items before mutating them in-place. Snapshot shares middle506+ // chunk pointers, so the matcher and terminal can race with us.507+ matcher.CancelScan()508+ terminal.PauseRendering()509+ // Reset cross-line ANSI state before re-processing all items510+ lineAnsiState = nil511+ prevLineAnsiState = nil512+ chunkList.ForEachItem(func(item *Item) {513+ origBytes := *item.origText514+ savedIndex := item.Index()515+ if newTransformer != nil {516+ transformItem(item, origBytes, newTransformer, savedIndex)517+ } else {518+ item.text, item.colors = ansiProcessor(origBytes)519+ }520+ item.text.Index = savedIndex521+ item.transformed = nil522+ }, func() {523+ nthTransformer = newTransformer524+ })525+ terminal.ResumeRendering()526+ matcher.ResumeScan()527+ withNthChanged = true528+ bump = true529+ }530 if bump {531 patternCache = make(map[string]*Pattern)532 cache.Clear()533 inputRevision.bumpMinor()35 unmodified lines569 terminal.UpdateHeader(GetItems(snapshot, int(headerLines)))570 } else {571 terminal.UpdateHeader(nil)572 }573+ } else if withNthChanged && headerLines > 0 {574+ terminal.UpdateHeader(GetItems(snapshot, int(headerLines)))575 }576 matcher.Reset(snapshot, input(), true, !reading, sort, snapshotRevision)577 delay = false578 53 unmodified linesmodified:src/matcher.go+21 added-2 removed
43 unmodified lines44 slab []*util.Slab45 sortBuf [][]Result46 mergerCache map[string]MatchResult47 revision revision48+ scanMutex sync.Mutex49+ cancelScan *util.AtomicBool50 }51 52 const (53 reqRetry util.EventType = iota17 unmodified lines71 partitions: partitions,72 slab: make([]*util.Slab, partitions),73 sortBuf: make([][]Result, partitions),74 mergerCache: make(map[string]MatchResult),73- revision: revision}75+ revision: revision,76+ cancelScan: util.NewAtomicBool(false)}77 }78 79 // Loop puts Matcher in action80 func (m *Matcher) Loop() {51 unmodified lines132 }133 }134 135 if result.merger == nil {136+ m.scanMutex.Lock()137 result = m.scan(request)138+ m.scanMutex.Unlock()139 }140 141 if !result.cancelled {142 if result.cacheable() {99 unmodified lines242 if count == numChunks {243 break244 }245 241- if m.reqBox.Peek(reqReset) {246+ if m.cancelScan.Get() || m.reqBox.Peek(reqReset) {247 return MatchResult{nil, nil, wait()}248 }249 250 if time.Since(startedAt) > progressMinDuration {22 unmodified lines273 }274 m.reqBox.Set(event, MatchRequest{chunks, pattern, final, sort, revision})275 }276 277+// CancelScan cancels any in-flight scan, waits for it to finish,278+// and prevents new scans from starting until ResumeScan is called.279+// This is used to safely mutate shared items (e.g., during with-nth changes).280+func (m *Matcher) CancelScan() {281+ m.cancelScan.Set(true)282+ m.scanMutex.Lock()283+ m.cancelScan.Set(false)284+}285+286+// ResumeScan allows scans to proceed again after CancelScan.287+func (m *Matcher) ResumeScan() {288+ m.scanMutex.Unlock()289+}290+291 func (m *Matcher) Stop() {292 m.reqBox.Set(reqQuit, nil)293 }modified:src/options.go+9 added-1 removed
586 unmodified lines587 Nth []Range588 FreezeLeft int589 FreezeRight int590 WithNth func(Delimiter) func([]Token, int32) string591+ WithNthExpr string592 AcceptNth func(Delimiter) func([]Token, int32) string593 Delimiter Delimiter594 Sort int595 Raw bool1033 unmodified lines1629 )1630 1631 func init() {1632 executeRegexp = regexp.MustCompile(1632- `(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|bg-transform|transform)-(?:query|prompt|(?:border|list|preview|input|header|footer)-label|header-lines|header|footer|search|nth|pointer|ghost)|bg-transform|transform|change-(?:preview-window|preview|multi)|(?:re|un|toggle-)bind|pos|put|print|search|trigger)`)1633+ `(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|bg-transform|transform)-(?:query|prompt|(?:border|list|preview|input|header|footer)-label|header-lines|header|footer|search|with-nth|nth|pointer|ghost)|bg-transform|transform|change-(?:preview-window|preview|multi)|(?:re|un|toggle-)bind|pos|put|print|search|trigger)`)1634 splitRegexp = regexp.MustCompile("[,:]+")1635 actionNameRegexp = regexp.MustCompile("(?i)^[a-z-]+")1636 }1637 434 unmodified lines2072 case "change-multi":2073 return actChangeMulti2074 case "change-nth":2075 return actChangeNth2076+ case "change-with-nth":2077+ return actChangeWithNth2078 case "pos":2079 return actPosition2080 case "execute":2081 return actExecute28 unmodified lines2110 case "transform-ghost":2111 return actTransformGhost2112 case "transform-nth":2113 return actTransformNth2114+ case "transform-with-nth":2115+ return actTransformWithNth2116 case "transform-pointer":2117 return actTransformPointer2118 case "transform-prompt":2119 return actTransformPrompt24 unmodified lines2144 case "bg-transform-ghost":2145 return actBgTransformGhost2146 case "bg-transform-nth":2147 return actBgTransformNth2148+ case "bg-transform-with-nth":2149+ return actBgTransformWithNth2150 case "bg-transform-pointer":2151 return actBgTransformPointer2152 case "bg-transform-prompt":2153 return actBgTransformPrompt633 unmodified lines2787 }2788 if opts.WithNth, err = nthTransformer(str); err != nil {2789 return err2790 }2791+ opts.WithNthExpr = str2792 case "--accept-nth":2793 str, err := nextString("nth expression required")2794 if err != nil {2795 return err1122 unmodified linesmodified:src/terminal.go+76 added-1 removed
338 unmodified lines339 freezeRight int340 nthAttr tui.Attr341 nth []Range342 nthCurrent []Range343+ withNthDefault string344+ withNthExpr string345+ withNthEnabled bool346 acceptNth func([]Token, int32) string347 tabstop int348 margin [4]sizeSpec349 padding [4]sizeSpec36 unmodified lines386 hasFocusActions bool387 hasLoadActions bool388 hasResizeActions bool389 triggerLoad bool390+ filterSelection bool391 reading bool392 running *util.AtomicBool393 failed *string394 jumping jumpMode159 unmodified lines554 actChangeInputLabel555 actChangeListLabel556 actChangeMulti557 actChangeNth558+ actChangeWithNth559 actChangePointer560 actChangePreview561 actChangePreviewLabel562 actChangePreviewWindow77 unmodified lines640 actTransformFooterLabel641 actTransformInputLabel642 actTransformListLabel643 actTransformNth644+ actTransformWithNth645 actTransformPointer646 actTransformPreviewLabel647 actTransformPrompt648 actTransformQuery11 unmodified lines660 actBgTransformFooterLabel661 actBgTransformInputLabel662 actBgTransformListLabel663 actBgTransformNth664+ actBgTransformWithNth665 actBgTransformPointer666 actBgTransformPreviewLabel667 actBgTransformPrompt668 actBgTransformQuery58 unmodified lines727 actTransformFooterLabel,728 actTransformInputLabel,729 actTransformListLabel,730 actTransformNth,731+ actTransformWithNth,732 actTransformPointer,733 actTransformPreviewLabel,734 actTransformPrompt,735 actTransformQuery,8 unmodified lines744 actBgTransformFooterLabel,745 actBgTransformInputLabel,746 actBgTransformListLabel,747 actBgTransformNth,748+ actBgTransformWithNth,749 actBgTransformPointer,750 actBgTransformPreviewLabel,751 actBgTransformPrompt,752 actBgTransformQuery,21 unmodified lines774 file bool775 raw bool776 }777 778+type withNthSpec struct {779+ fn func([]Token, int32) string // nil = clear (restore original)780+}781+782 type searchRequest struct {783 sort bool784 sync bool785 nth *[]Range786+ withNth *withNthSpec787 headerLines *int788 command *commandSpec789 environ []string790 changed bool302 unmodified lines1093 freezeRight: opts.FreezeRight,1094 nthAttr: opts.Theme.Nth.Attr,1095 nth: opts.Nth,1096 nthCurrent: opts.Nth,1097+ withNthDefault: opts.WithNthExpr,1098+ withNthExpr: opts.WithNthExpr,1099+ withNthEnabled: opts.WithNth != nil,1100 tabstop: opts.Tabstop,1101 raw: opts.Raw,1102 hasStartActions: false,1103 hasResultActions: false,263 unmodified lines1367 env = append(env, "FZF_DIRECTION="+direction)1368 if len(t.nthCurrent) > 0 {1369 env = append(env, "FZF_NTH="+RangesToString(t.nthCurrent))1370 }1371+ if len(t.withNthExpr) > 0 {1372+ env = append(env, "FZF_WITH_NTH="+t.withNthExpr)1373+ }1374 if t.raw {1375 val := "0"1376 if t.isCurrentItemMatch() {1377 val = "1"361 unmodified lines1739 }1740 return paused, copySlice(src)1741 }1742 1743+// PauseRendering blocks the terminal from reading items.1744+// Must be paired with ResumeRendering.1745+func (t *Terminal) PauseRendering() {1746+ t.mutex.Lock()1747+}1748+1749+// ResumeRendering releases the lock acquired by PauseRendering.1750+func (t *Terminal) ResumeRendering() {1751+ t.mutex.Unlock()1752+}1753+1754 // UpdateCount updates the count information1755 func (t *Terminal) UpdateCount(cnt int, final bool, failedCommand *string) {1756 t.mutex.Lock()1757 t.count = cnt114 unmodified lines1872 t.selected = filtered1873 }1874 t.revision = newRevision1875 t.version++1876+1877+ // Filter out selections that no longer match after with-nth change.1878+ // Must be inside the revision check so we don't consume the flag1879+ // on a stale EvtSearchFin from a previous search.1880+ if t.filterSelection && t.multi > 0 && len(t.selected) > 0 {1881+ matchMap := t.resultMerger.ToMap()1882+ filtered := make(map[int32]selectedItem)1883+ for k, v := range t.selected {1884+ if _, matched := matchMap[k]; matched {1885+ filtered[k] = v1886+ }1887+ }1888+ t.selected = filtered1889+ }1890+ t.filterSelection = false1891 }1892 if t.triggerLoad {1893 t.triggerLoad = false1894 t.eventChan <- tui.Load.AsEvent()4072 unmodified lines5967 // These variables are defined outside the loop to be accessible from closures5968 events := []util.EventType{}5969 changed := false5970 var newNth *[]Range5971+ var newWithNth *withNthSpec5972 var newHeaderLines *int5973 req := func(evts ...util.EventType) {5974 for _, event := range evts {5975 events = append(events, event)9 unmodified lines5985 var reloadSync bool5986 events = []util.EventType{}5987 changed = false5988 newNth = nil5989+ newWithNth = nil5990 newHeaderLines = nil5991 beof := false5992 queryChanged := false5993 denylist := []int32{}383 unmodified lines6377 t.nthCurrent = *newNth6378 t.forceRerenderList()6379 }6380 })6381+ case actChangeWithNth, actTransformWithNth, actBgTransformWithNth:6382+ if !t.withNthEnabled {6383+ break Action6384+ }6385+ capture(true, func(expr string) {6386+ tokens := strings.Split(expr, "|")6387+ withNthExpr := tokens[0]6388+ if len(tokens) > 1 {6389+ a.a = strings.Join(append(tokens[1:], tokens[0]), "|")6390+ }6391+ // Empty value restores the default --with-nth6392+ if len(withNthExpr) == 0 {6393+ withNthExpr = t.withNthDefault6394+ }6395+ if withNthExpr != t.withNthExpr {6396+ if factory, err := nthTransformer(withNthExpr); err == nil {6397+ newWithNth = &withNthSpec{fn: factory(t.delimiter)}6398+ } else {6399+ return6400+ }6401+ t.withNthExpr = withNthExpr6402+ t.filterSelection = true6403+ changed = true6404+ t.clearNumLinesCache()6405+ t.forceRerenderList()6406+ }6407+ })6408 case actChangeQuery:6409 t.input = []rune(a.a)6410 t.cx = len(t.input)6411 case actChangeHeader, actTransformHeader, actBgTransformHeader:1139 unmodified lines7551 7552 reload := changed || newCommand != nil7553 var reloadRequest *searchRequest7554 if reload {7480- reloadRequest = &searchRequest{sort: t.sort, sync: reloadSync, nth: newNth, headerLines: newHeaderLines, command: newCommand, environ: t.environ(), changed: changed, denylist: denylist, revision: t.resultMerger.Revision()}7555+ reloadRequest = &searchRequest{sort: t.sort, sync: reloadSync, nth: newNth, withNth: newWithNth, headerLines: newHeaderLines, command: newCommand, environ: t.environ(), changed: changed, denylist: denylist, revision: t.resultMerger.Revision()}7556 }7557 7558 // Dispatch queued background requests7559 t.dispatchAsync()227 unmodified linesmodified:test/test_core.rb+185 added
1743 unmodified lines1744 assert_equal 4, lines.match_count1745 end1746 end1747 1748+ def test_change_with_nth1749+ input = [1750+ 'foo bar baz',1751+ 'aaa bbb ccc',1752+ 'xxx yyy zzz'1753+ ]1754+ writelines(input)1755+ # Start with field 1 only, cycle through fields, verify $FZF_WITH_NTH via prompt1756+ tmux.send_keys %(#{FZF} --with-nth 1 --bind 'space:change-with-nth(2|3|1),result:transform-prompt:echo "[$FZF_WITH_NTH]> "' < #{tempname}), :Enter1757+ tmux.until do |lines|1758+ assert_equal 3, lines.item_count1759+ assert lines.any_include?('[1]>')1760+ assert lines.any_include?('foo')1761+ refute lines.any_include?('bar')1762+ end1763+ tmux.send_keys :Space1764+ tmux.until do |lines|1765+ assert lines.any_include?('[2]>')1766+ assert lines.any_include?('bar')1767+ refute lines.any_include?('foo')1768+ end1769+ tmux.send_keys :Space1770+ tmux.until do |lines|1771+ assert lines.any_include?('[3]>')1772+ assert lines.any_include?('baz')1773+ refute lines.any_include?('bar')1774+ end1775+ tmux.send_keys :Space1776+ tmux.until do |lines|1777+ assert lines.any_include?('[1]>')1778+ assert lines.any_include?('foo')1779+ refute lines.any_include?('bar')1780+ end1781+ end1782+1783+ def test_change_with_nth_default1784+ # Empty value restores the default --with-nth1785+ tmux.send_keys %(echo -e 'a b c\nd e f' | #{FZF} --with-nth 1 --bind 'space:change-with-nth(2|)'), :Enter1786+ tmux.until do |lines|1787+ assert_equal 2, lines.item_count1788+ assert lines.any_include?('a')1789+ refute lines.any_include?('b')1790+ end1791+ # Switch to field 21792+ tmux.send_keys :Space1793+ tmux.until do |lines|1794+ assert lines.any_include?('b')1795+ refute lines.any_include?('a')1796+ end1797+ # Empty restores default (field 1)1798+ tmux.send_keys :Space1799+ tmux.until do |lines|1800+ assert lines.any_include?('a')1801+ refute lines.any_include?('b')1802+ end1803+ end1804+1805+ def test_transform_with_nth_search1806+ input = [1807+ 'alpha bravo charlie',1808+ 'delta echo foxtrot',1809+ 'golf hotel india'1810+ ]1811+ writelines(input)1812+ tmux.send_keys %(#{FZF} --with-nth 1 --bind 'space:transform-with-nth(echo 2)' -q '^bravo$' < #{tempname}), :Enter1813+ tmux.until do |lines|1814+ assert_equal 0, lines.match_count1815+ end1816+ tmux.send_keys :Space1817+ tmux.until do |lines|1818+ assert_equal 1, lines.match_count1819+ end1820+ end1821+1822+ def test_bg_transform_with_nth_output1823+ tmux.send_keys %(echo -e 'a b c\nd e f' | #{FZF} --with-nth 2 --bind 'space:bg-transform-with-nth(echo 3)'), :Enter1824+ tmux.until do |lines|1825+ assert_equal 2, lines.item_count1826+ assert lines.any_include?('b')1827+ end1828+ tmux.send_keys :Space1829+ tmux.until do |lines|1830+ assert lines.any_include?('c')1831+ refute lines.any_include?('b')1832+ end1833+ tmux.send_keys :Enter1834+ tmux.until { |lines| assert lines.any_include?('a b c') || lines.any_include?('d e f') }1835+ end1836+1837+ def test_change_with_nth_search1838+ input = [1839+ 'alpha bravo charlie',1840+ 'delta echo foxtrot',1841+ 'golf hotel india'1842+ ]1843+ writelines(input)1844+ tmux.send_keys %(#{FZF} --with-nth 1 --bind 'space:change-with-nth(2)' -q '^bravo$' < #{tempname}), :Enter1845+ tmux.until do |lines|1846+ assert_equal 0, lines.match_count1847+ end1848+ tmux.send_keys :Space1849+ tmux.until do |lines|1850+ assert_equal 1, lines.match_count1851+ end1852+ end1853+1854+ def test_change_with_nth_output1855+ tmux.send_keys %(echo -e 'a b c\nd e f' | #{FZF} --with-nth 2 --bind 'space:change-with-nth(3)'), :Enter1856+ tmux.until do |lines|1857+ assert_equal 2, lines.item_count1858+ assert lines.any_include?('b')1859+ end1860+ tmux.send_keys :Space1861+ tmux.until do |lines|1862+ assert lines.any_include?('c')1863+ refute lines.any_include?('b')1864+ end1865+ tmux.send_keys :Enter1866+ tmux.until { |lines| assert lines.any_include?('a b c') || lines.any_include?('d e f') }1867+ end1868+1869+ def test_change_with_nth_selection1870+ # Items: field1 has unique values, field2 has 'match' or 'miss'1871+ input = [1872+ 'one match x',1873+ 'two miss y',1874+ 'three match z'1875+ ]1876+ writelines(input)1877+ # Start showing field 2 (match/miss), query 'match', select all matches, then switch to field 31878+ tmux.send_keys %(#{FZF} --with-nth 2 --multi --bind 'ctrl-a:select-all,space:change-with-nth(3)' -q match < #{tempname}), :Enter1879+ tmux.until do |lines|1880+ assert_equal 2, lines.match_count1881+ end1882+ # Select all matching items1883+ tmux.send_keys 'C-a'1884+ tmux.until do |lines|1885+ assert lines.any_include?('(2)')1886+ end1887+ # Now change with-nth to field 3; 'x' and 'z' don't contain 'match'1888+ tmux.send_keys :Space1889+ tmux.until do |lines|1890+ assert_equal 0, lines.match_count1891+ # Selections of non-matching items should be cleared1892+ assert lines.any_include?('(0)')1893+ end1894+ end1895+1896+ def test_change_with_nth_multiline1897+ # Each item has 3 lines: "N-a\nN-b\nN-c"1898+ # --with-nth 1 shows 1 line per item, --with-nth 1..3 shows 3 lines per item1899+ tmux.send_keys %(seq 20 | xargs -I{} printf '{}-a\\n{}-b\\n{}-c\\0' | #{FZF} --read0 --delimiter "\n" --with-nth 1 --bind 'space:change-with-nth(1..3|1)' --no-sort), :Enter1900+ tmux.until do |lines|1901+ assert_equal 20, lines.item_count1902+ assert lines.any_include?('1-a')1903+ refute lines.any_include?('1-b')1904+ end1905+ # Expand to 3 lines per item1906+ tmux.send_keys :Space1907+ tmux.until do |lines|1908+ assert lines.any_include?('1-a')1909+ assert lines.any_include?('1-b')1910+ assert lines.any_include?('1-c')1911+ end1912+ # Scroll down a few items1913+ 5.times { tmux.send_keys :Down }1914+ tmux.until do |lines|1915+ assert lines.any_include?('6-a')1916+ assert lines.any_include?('6-b')1917+ assert lines.any_include?('6-c')1918+ end1919+ # Collapse back to 1 line per item1920+ tmux.send_keys :Space1921+ tmux.until do |lines|1922+ assert lines.any_include?('6-a')1923+ refute lines.any_include?('6-b')1924+ end1925+ # Scroll down more after collapse1926+ 5.times { tmux.send_keys :Down }1927+ tmux.until do |lines|1928+ assert lines.any_include?('11-a')1929+ refute lines.any_include?('11-b')1930+ end1931+ end1932+1933 def test_env_vars1934 def env_vars1935 return {} unless File.exist?(tempname)1936 510 unmodified linesmodified:CHANGELOG.md+8 added
1 CHANGELOG2 =========3 4+0.69.05+------6+- Added `change-with-nth` action for dynamically changing the `--with-nth` option7+ ```sh8+ echo -e "a b c\nd e f\ng h i" | fzf --with-nth .. \9+ --bind 'space:change-with-nth(1|2|3|1,3|2,3|)'10+ ```11+12 0.68.013 ------14 - Implemented word wrapping in the list section15 - Added `--wrap=word` (or `--wrap-word`) option and `toggle-wrap-word` action for word-level line wrapping in the list section3167 unmodified lines