Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
87314996
Commit
87314996
authored
Sep 27, 2022
by
Christoph Cullmann
🍨
Browse files
ensure project view is better in sync with initial open document
parent
4f9493e3
Pipeline
#237364
failed with stage
in 6 minutes and 39 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojectplugin.cpp
View file @
87314996
...
...
@@ -81,44 +81,6 @@ KateProjectPlugin::KateProjectPlugin(QObject *parent, const QList<QVariant> &)
// forward to meta-object system friendly version
connect
(
this
,
&
KateProjectPlugin
::
projectCreated
,
this
,
&
KateProjectPlugin
::
projectAdded
);
connect
(
this
,
&
KateProjectPlugin
::
pluginViewProjectClosing
,
this
,
&
KateProjectPlugin
::
projectRemoved
);
/**
* delay activation after session restore
* we do this both for session restoration to not take preference and
* to be able to signal errors during project loading via message() signals
*/
QTimer
::
singleShot
(
0
,
this
,
[
this
]()
{
// open directories as projects
KateProject
*
projectToActivate
=
nullptr
;
auto
args
=
qApp
->
arguments
();
args
.
removeFirst
();
// The first argument is the executable name
for
(
const
QString
&
arg
:
qAsConst
(
args
))
{
QFileInfo
info
(
arg
);
if
(
info
.
isDir
())
{
projectToActivate
=
projectForDir
(
info
.
absoluteFilePath
(),
true
);
}
}
#ifdef HAVE_CTERMID
/**
* open project for our current working directory, if this kate has a terminal
* https://stackoverflow.com/questions/1312922/detect-if-stdin-is-a-terminal-or-pipe-in-c-c-qt
*/
if
(
!
projectToActivate
)
{
char
tty
[
L_ctermid
+
1
]
=
{
0
};
ctermid
(
tty
);
if
(
int
fd
=
::
open
(
tty
,
O_RDONLY
);
fd
>=
0
)
{
projectToActivate
=
projectForDir
(
QDir
::
current
());
::
close
(
fd
);
}
}
#endif
// if we have some project opened, ensure it is the active one, this happens after session restore
if
(
projectToActivate
)
{
Q_EMIT
activateProject
(
projectToActivate
);
}
});
}
KateProjectPlugin
::~
KateProjectPlugin
()
...
...
@@ -673,6 +635,49 @@ void KateProjectPlugin::readSessionConfig(const KConfigGroup &config)
// we might arrive here if invalid data is store, just ignore that, we just loose session data
}
}
// always load projects from command line or current working directory first time we arrive here
if
(
m_initialReadSessionConfigDone
)
{
return
;
}
m_initialReadSessionConfigDone
=
true
;
/**
* delayed activation after session restore
* we do this both for session restoration to not take preference and
* to be able to signal errors during project loading via message() signals
*/
KateProject
*
projectToActivate
=
nullptr
;
// open directories as projects
auto
args
=
qApp
->
arguments
();
args
.
removeFirst
();
// The first argument is the executable name
for
(
const
QString
&
arg
:
qAsConst
(
args
))
{
QFileInfo
info
(
arg
);
if
(
info
.
isDir
())
{
projectToActivate
=
projectForDir
(
info
.
absoluteFilePath
(),
true
);
}
}
#ifdef HAVE_CTERMID
/**
* open project for our current working directory, if this kate has a terminal
* https://stackoverflow.com/questions/1312922/detect-if-stdin-is-a-terminal-or-pipe-in-c-c-qt
*/
if
(
!
projectToActivate
)
{
char
tty
[
L_ctermid
+
1
]
=
{
0
};
ctermid
(
tty
);
if
(
int
fd
=
::
open
(
tty
,
O_RDONLY
);
fd
>=
0
)
{
projectToActivate
=
projectForDir
(
QDir
::
current
());
::
close
(
fd
);
}
}
#endif
// if we have some project opened, ensure it is the active one, this happens after session restore
if
(
projectToActivate
)
{
Q_EMIT
activateProject
(
projectToActivate
);
}
}
void
KateProjectPlugin
::
writeSessionConfig
(
KConfigGroup
&
config
)
...
...
addons/project/kateprojectplugin.h
View file @
87314996
...
...
@@ -261,6 +261,9 @@ private:
*/
std
::
unordered_map
<
KTextEditor
::
Document
*
,
KateProject
*>
m_document2Project
;
// remember if we did the initial read session config
bool
m_initialReadSessionConfigDone
=
false
;
/**
* Project completion
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment