mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Autosaved dimensions do not override vimrc
Setting 'lines' and 'columns' in .vimrc works again. This patch also fixes a minor memory leak related to the autosaved dimensions. Finally, skip checking terminal capabilies when the GUI is about to start.
This commit is contained in:
+24
-23
@@ -110,6 +110,30 @@ gui_mch_prepare(int *argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
/* Called directly after forking (even if we didn't fork). */
|
||||
void
|
||||
gui_macvim_after_fork_init()
|
||||
{
|
||||
ASLInit();
|
||||
ASLogDebug(@"");
|
||||
|
||||
// Restore autosaved rows & columns
|
||||
CFIndex rows, cols;
|
||||
Boolean rowsValid, colsValid;
|
||||
rows = CFPreferencesGetAppIntegerValue((CFStringRef)MMAutosaveRowsKey,
|
||||
kCFPreferencesCurrentApplication,
|
||||
&rowsValid);
|
||||
cols = CFPreferencesGetAppIntegerValue((CFStringRef)MMAutosaveColumnsKey,
|
||||
kCFPreferencesCurrentApplication,
|
||||
&colsValid);
|
||||
if (rowsValid && colsValid
|
||||
&& (rows > 4 && rows < 1000 && cols > 29 && cols < 4000)) {
|
||||
gui.num_rows = rows;
|
||||
gui.num_cols = cols;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check if the GUI can be started. Called before gvimrc is sourced.
|
||||
* Return OK or FAIL.
|
||||
@@ -117,29 +141,6 @@ gui_mch_prepare(int *argc, char **argv)
|
||||
int
|
||||
gui_mch_init_check(void)
|
||||
{
|
||||
ASLInit();
|
||||
ASLogDebug(@"");
|
||||
|
||||
// Restore autosaved rows & columns
|
||||
CFNumberRef rowsRef, colsRef;
|
||||
rowsRef = CFPreferencesCopyAppValue((CFStringRef)MMAutosaveRowsKey,
|
||||
kCFPreferencesCurrentApplication);
|
||||
colsRef = CFPreferencesCopyAppValue((CFStringRef)MMAutosaveColumnsKey,
|
||||
kCFPreferencesCurrentApplication);
|
||||
if (rowsRef && colsRef) {
|
||||
int rows, cols;
|
||||
if (CFNumberGetValue(rowsRef, kCFNumberIntType, &rows)
|
||||
&& CFNumberGetValue(colsRef, kCFNumberIntType, &cols)) {
|
||||
if (rows > 4 && rows < 1000 && cols > 29 && cols < 4000) {
|
||||
Rows = rows;
|
||||
Columns = cols;
|
||||
} else {
|
||||
ASLogWarn(@"Autosaved window dimensions invalid: %dx%d",
|
||||
cols, rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -363,6 +363,9 @@ main
|
||||
#ifdef MACOS_X
|
||||
if (gui.starting && gui.dofork)
|
||||
macosx_fork(); /* Never returns */
|
||||
# ifdef FEAT_GUI_MACVIM
|
||||
gui_macvim_after_fork_init();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -452,7 +455,8 @@ main
|
||||
* For GTK we can't be sure, but when started from the desktop it doesn't
|
||||
* make sense to try using a terminal.
|
||||
*/
|
||||
#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
|
||||
#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \
|
||||
|| defined(FEAT_GUI_MACVIM)
|
||||
if (gui.starting
|
||||
# ifdef FEAT_GUI_GTK
|
||||
&& !isatty(2)
|
||||
@@ -461,7 +465,7 @@ main
|
||||
params.want_full_screen = FALSE;
|
||||
#endif
|
||||
|
||||
#if (defined(FEAT_GUI_MAC) || defined(FEAT_GUI_MACVIM)) && defined(MACOS_X_UNIX)
|
||||
#if defined(FEAT_GUI_MAC) && defined(MACOS_X_UNIX)
|
||||
/* When the GUI is started from Finder, need to display messages in a
|
||||
* message box. isatty(2) returns TRUE anyway, thus we need to check the
|
||||
* name to know we're not started from a terminal. */
|
||||
@@ -469,7 +473,6 @@ main
|
||||
{
|
||||
params.want_full_screen = FALSE;
|
||||
|
||||
# ifndef FEAT_GUI_MACVIM
|
||||
/* Avoid always using "/" as the current directory. Note that when
|
||||
* started from Finder the arglist will be filled later in
|
||||
* HandleODocAE() and "fname" will be NULL. */
|
||||
@@ -484,7 +487,6 @@ main
|
||||
vim_chdir(NameBuff);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
macvim_early_init();
|
||||
void
|
||||
gui_mch_prepare(int *argc, char **argv);
|
||||
void
|
||||
gui_macvim_after_fork_init();
|
||||
int
|
||||
gui_mch_init_check(void);
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user