diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index 3ad3dbddd0..d4b97dc7a9 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -1516,6 +1516,31 @@ gui_macvim_update_modified_flag() [[MMBackend sharedInstance] updateModifiedFlag]; } +/* + * Add search pattern 'pat' to the OS X find pasteboard. This allows other + * apps access the last pattern searched for (hitting in another app will + * initiate a search for the same pattern). + */ + void +gui_macvim_add_to_find_pboard(char_u *pat) +{ + if (!pat) return; + +#ifdef FEAT_MBYTE + pat = CONVERT_TO_UTF8(pat); +#endif + NSString *s = [NSString stringWithUTF8String:(char*)pat]; +#ifdef FEAT_MBYTE + CONVERT_TO_UTF8_FREE(pat); +#endif + + if (!s) return; + + NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSFindPboard]; + [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; + [pb setString:s forType:NSStringPboardType]; +} + diff --git a/src/normal.c b/src/normal.c index c509d774a2..acf58f87bb 100644 --- a/src/normal.c +++ b/src/normal.c @@ -6111,6 +6111,10 @@ normal_search(cap, dir, pat, opt) cap->oap->use_reg_one = TRUE; curwin->w_set_curswant = TRUE; +#if FEAT_GUI_MACVIM + gui_macvim_add_to_find_pboard(pat); +#endif + i = do_search(cap->oap, dir, pat, cap->count1, opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL); if (i == 0) diff --git a/src/proto/gui_macvim.pro b/src/proto/gui_macvim.pro index 0b9437e412..12fab1319c 100644 --- a/src/proto/gui_macvim.pro +++ b/src/proto/gui_macvim.pro @@ -194,6 +194,7 @@ void gui_mch_enter_fullscreen(void); void gui_mch_leave_fullscreen(void); void gui_macvim_update_modified_flag(); +void gui_macvim_add_to_find_pboard(char_u *pat); OSErr odb_buffer_close(buf_T *buf); OSErr odb_post_buffer_write(buf_T *buf);