Skip to content

Commit fa3b48c

Browse files
committed
Control sharing the find pasteboard with defaults
`MMShareFindPboard` default is `YES`. $ defaults write org.vim.MacVim MMShareFindPboard -bool NO
1 parent 6458d0b commit fa3b48c

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

src/MacVim/MMAppController.m

+1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ + (void)initialize
234234
[NSNumber numberWithBool:YES], MMNativeFullScreenKey,
235235
[NSNumber numberWithDouble:0.25], MMFullScreenFadeTimeKey,
236236
[NSNumber numberWithBool:NO], MMUseCGLayerAlwaysKey,
237+
[NSNumber numberWithBool:YES], MMShareFindPboardKey,
237238
nil];
238239

239240
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];

src/MacVim/MMWindowController.m

+7-3
Original file line numberDiff line numberDiff line change
@@ -1544,10 +1544,14 @@ - (void)doFindNext:(BOOL)next
15441544

15451545
// See gui_macvim_add_to_find_pboard() for an explanation of these
15461546
// types.
1547-
if ([bestType isEqual:VimFindPboardType])
1547+
if ([bestType isEqual:VimFindPboardType]) {
15481548
query = [pb stringForType:VimFindPboardType];
1549-
else
1550-
query = [pb stringForType:NSStringPboardType];
1549+
} else {
1550+
BOOL shareFindPboard = [[NSUserDefaults standardUserDefaults]
1551+
boolForKey:MMShareFindPboardKey];
1552+
if (shareFindPboard)
1553+
query = [pb stringForType:NSStringPboardType];
1554+
}
15511555
}
15521556

15531557
NSString *input = nil;

src/MacVim/MacVim.h

+3
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ extern NSString *MMLogToStdErrKey;
314314
// (techincally this is a user default but should not be used as such).
315315
extern NSString *MMNoWindowKey;
316316

317+
// Argument used to control MacVim sharing search text via the Find Pasteboard.
318+
extern NSString *MMShareFindPboardKey;
319+
317320
extern NSString *MMAutosaveRowsKey;
318321
extern NSString *MMAutosaveColumnsKey;
319322
extern NSString *MMRendererKey;

src/MacVim/MacVim.m

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
// (techincally this is a user default but should not be used as such).
119119
NSString *MMNoWindowKey = @"MMNoWindow";
120120

121+
NSString *MMShareFindPboardKey = @"MMShareFindPboard";
122+
121123
NSString *MMAutosaveRowsKey = @"MMAutosaveRows";
122124
NSString *MMAutosaveColumnsKey = @"MMAutosaveColumns";
123125
NSString *MMRendererKey = @"MMRenderer";

src/MacVim/gui_macvim.m

+12-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
static int MMMinFontSize = 6;
3737
static int MMMaxFontSize = 100;
3838

39+
static BOOL MMShareFindPboard = YES;
3940

4041
static GuiFont gui_macvim_font_with_name(char_u *name);
4142
static int specialKeyToNSKey(int key);
@@ -198,6 +199,15 @@
198199
// signs.
199200
use_graphical_sign = (val == MMRendererCoreText);
200201
}
202+
203+
// Check to use the Find Pasteboard.
204+
MMShareFindPboard = CFPreferencesGetAppBooleanValue((CFStringRef)MMShareFindPboardKey,
205+
kCFPreferencesCurrentApplication,
206+
&keyValid);
207+
if (!keyValid) {
208+
// Share text via the Find Pasteboard by default.
209+
MMShareFindPboard = YES;
210+
}
201211
}
202212

203213

@@ -1816,7 +1826,8 @@
18161826
// The second entry will be used by other applications when taking entries
18171827
// off the Find pasteboard, whereas MacVim will use the first if present.
18181828
[pb setString:s forType:VimFindPboardType];
1819-
[pb setString:[s stringByRemovingFindPatterns] forType:NSStringPboardType];
1829+
if (MMShareFindPboard)
1830+
[pb setString:[s stringByRemovingFindPatterns] forType:NSStringPboardType];
18201831
}
18211832

18221833
void

0 commit comments

Comments
 (0)