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

--patch not working on specific diff #473

Open
iloveitaly opened this issue Jul 20, 2023 · 6 comments
Open

--patch not working on specific diff #473

iloveitaly opened this issue Jul 20, 2023 · 6 comments
Labels

Comments

@iloveitaly
Copy link

--patch is not working on a specific diff:

image

It works with most diffs I've run into, but this one seems to cause it issues:

:100644 100644 ec47e8d 0000000 M	.tmux.conf

diff --git i/.tmux.conf w/.tmux.conf
index ec47e8d..399aad8 100644
--- i/.tmux.conf
+++ w/.tmux.conf
@@ -15,8 +15,7 @@ set -g @plugin 'wfxr/tmux-fzf-url'
 # TODO need status bar for this to be useful
 # set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
 # prefix-y to copy, prefix-shift-y to copy and paste
-# set -g @plugin 'tmux-plugins/tmux-yank'
-set -g @plugin 'iloveitaly/tmux-yank#put-with-bracketed-paste'
+set -g @plugin 'tmux-plugins/tmux-yank'
 # prefix-/ and prefix-f for pre-built file search
 # set -g @plugin 'tmux-plugins/tmux-copycat'
 # TODO https://github.com/jabirali/tmux-tilish
@@ -82,6 +81,15 @@ set -g @yank_with_mouse off
 # I don't like the status bar taking up screen real estate
 set -g status off
 
+# TODO will this fix my nano problems?
+# set -s escape-time 0
+
+# TODO not sure exactly how this works yet
+set -s focus-events on
+
+# TODO https://github.com/abhinav/tmux-fastcopy/issues/160
+# set -g destroy-unattached on
+
 # makes scrolling seem more macos-like
 set -g @scroll-speed-num-lines-per-scroll 3
 # allows less and other pagers to use the scroll wheel!
@@ -98,14 +106,23 @@ set-option -ga terminal-overrides ",xterm-256color:Tc"
 
 # Enable CSI u, this makes iterm play better with tmux
 # https://github.com/tmux/tmux/wiki/Modifier-Keys#extended-keys
-set -g extended-keys on
-set -sag terminal-features 'xterm*:extkeys'
+set -s extended-keys on
+set -as terminal-features 'xterm*:extkeys'
 
+# TODO https://github.com/abhinav/tmux-fastcopy/issues/155 jump to selection instead of copying
 # modify file regex to include line and column numbers
 set-option -g @fastcopy-regex-path "(?:[\\w\\-\\.]+|~)?(?:/[\\w\\-\\.@]+){2,}(?:\\:\\d+)?(?:\\:\\d+)?\\b"
-set-option -g @fastcopy-shift-action '/Users/mike/.open-file-path.sh {}'
+set-option -g @fastcopy-regex-stacktrace-path "(?:[\\w\\-\\.@/]+){2,}(?:\\:\\d+)(?:\\:\\d+)?\\b"
 
-set-option -g @open '/Users/mike/.open-file-path.sh'
+# open file in editor on shift-{letter}
+# default action is copy to clipboard
+set-option -g @fastcopy-shift-action '/Users/mike/.open-file-path.sh {}'
+set-option -g @open-editor '/Users/mike/.open-file-path.sh'
+
+###########################
+# Copy Mode Navigation
+# helpful shortcuts for jumping to content in the buffer very quickly
+###########################
 
 # easily jump to prompt starts
 # https://unix.stackexchange.com/questions/226731/jump-to-last-prompt-in-terminal-or-tmux
@@ -114,6 +131,34 @@ bind-key -T copy-mode-vi b {
   send-keys -X search-backward "❯"
 }
 
+# easily jump to jest errors, j for jest
+bind-key -T copy-mode-vi j {
+  send-keys -X start-of-line
+  send-keys -X search-backward " ● "
+}
+
+# copy to EOL and trim trailing newline, and trailing/leading whitespace
+bind-key -T copy-mode-vi C-D {
+  send-keys -X copy-pipe-end-of-line-and-cancel "tr -d '\\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | tmux paste-buffer -p"
+}
+
+# TODO add copy entire line shortcut, regardless of current cursor
+
+###########################
+# Fast Searching
+# similar to copycat, but using the native search so it's fast (https://github.com/tmux-plugins/tmux-copycat/tree/master)
+###########################
+
+# `/` for quick, interactive searches
+bind-key / command-prompt -i -I "#{pane_search_string}" -T search -p "search" { copy-mode -e; send-keys -X search-backward-incremental "%%" }
+
+# TODO file search https://github.com/tmux-plugins/tmux-copycat/issues/148
+# bind-key f {
+#   send-keys -X search-backward '[a-zA-Z0-9_./-@]+$'
+# }
+
+# TODO add url, file, git sha, etc searches; pull from copycat
+
 ###########################
 # iTerm rebindings
 # In iterm when CSI U mode (extended key mode) is enabled tmux sees M-Left & M-Right arrow keys directly, unlike xterm.js
@@ -153,9 +198,34 @@ bind-key -T copy-mode-vi M-f send-keys -X next-word
 bind-key -T copy-mode-vi M-b send-keys -X previous-word
 
 ###########################
+# Keyboard Based Copy Mode Navigation
 # allow Shift-{Arrows} to be used to start selection AND mutate selection, like macos
 ###########################
 
+bind-key -n S-M-Right {
+  select-pane
+  copy-mode -M
+
+  if-shell -F '#{selection_present}' {
+    send-keys -X next-word
+  } {
+    send-keys -X begin-selection
+    send-keys -X next-word
+  }
+}
+
+bind-key -n S-M-Left {
+  select-pane
+  copy-mode -M
+
+  if-shell -F '#{selection_present}' {
+    send-keys -X previous-word
+  } {
+    send-keys -X begin-selection
+    send-keys -X previous-word
+  }
+}
+
 bind-key -T copy-mode-vi 'S-Down' {
   if-shell -F '#{selection_present}' {
     send-keys -X cursor-down
@@ -258,4 +328,4 @@ unbind -T copy-mode TripleClick1Pane
 # this is at the bottom because it messes with syntax highlighting
 # align word separators with a more standard terminal
 # https://github.com/tmux/tmux/issues/3528
-set-option -g word-separators " ()[]{}',:;\""
+set-option -g word-separators " ()[]{}',:;\""
\ No newline at end of file
@OJFord OJFord added the bug label Jul 21, 2023
@HaleTom
Copy link

HaleTom commented Jul 21, 2023

The issue is in the final few lines:

% tail -n6 specimen
 # this is at the bottom because it messes with syntax highlighting
 # align word separators with a more standard terminal
 # https://github.com/tmux/tmux/issues/3528
-set-option -g word-separators " ()[]{}',:;\""
+set-option -g word-separators " ()[]{}',:;\""
\ No newline at end of file
%
% diff-so-fancy --patch < specimen | tail -n6
# https://github.com/tmux/tmux/issues/3528
set-option -g word-separators " ()[]{}',:;\""

set-option -g word-separators " ()[]{}',:;\""

\ No newline at end of file
%

These two blank lines account for the line count mismatch:

% diff-so-fancy --patch < specimen | wc -l
139
% wc -l specimen
137 specimen
%
% diff-so-fancy --version
Diff-so-fancy: https://github.com/so-fancy/diff-so-fancy
Version      : 1.4.4

@HaleTom
Copy link

HaleTom commented Jul 21, 2023

#474 is also caused by two blank lines being added (but this time at the top). See there for a workaround, also.

@iloveitaly
Copy link
Author

Thanks for calling that out! I'm using that workaround, but would be awesome if we could somehow fix this in the core library.

This causes downstream issues when using something like git-fuzzy since the command used for patching can't be customized.

@HaleTom
Copy link

HaleTom commented Jul 24, 2023

This causes downstream issues when using something like git-fuzzy since the command used for patching can't be customized.

I believe it only affects interactive mode, does git fuzzy support that?

@iloveitaly
Copy link
Author

Yes, git-fuzzy does support that; and yup that's the mode I'm running into this on.

@HaleTom
Copy link

HaleTom commented Feb 23, 2024

Related issues:
#35 #305 #296 #437 #474

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

No branches or pull requests

3 participants