<p>Hi,</p>
<p>This PR causes Geany to save the project whenever a file is opened or closed.</p>
<p>The main issue it has is when opening/closing multiple files it saves the project file between each file.<br>
This does not happen on startup or when quitting but could still be an issue.</p>
<p>It should fix <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="314617872" data-permission-text="Issue title is private" data-url="https://github.com/geany/geany/issues/1826" href="https://github.com/geany/geany/issues/1826">#1826</a></p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/geany/geany/pull/1860'>https://github.com/geany/geany/pull/1860</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Save project when opening or closing files</li>
  <li>Don't try to save project if none is open</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/geany/geany/pull/1860/files#diff-0">src/document.c</a>
    (17)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/geany/geany/pull/1860.patch'>https://github.com/geany/geany/pull/1860.patch</a></li>
  <li><a href='https://github.com/geany/geany/pull/1860.diff'>https://github.com/geany/geany/pull/1860.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/1860">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ1z_J4VpmcecyRvz2naLasB9cNKFks5t1YQ-gaJpZM4UKt8l">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABDrJ2dRANeCwFk-1oDX5XjLzC5YPehaks5t1YQ-gaJpZM4UKt8l.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","potentialAction":{"@type":"ViewAction","target":"https://github.com/geany/geany/pull/1860","url":"https://github.com/geany/geany/pull/1860","name":"View Pull Request"},"description":"View this Pull Request on GitHub","publisher":{"@type":"Organization","name":"GitHub","url":"https://github.com"}}</script>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Save project on file open/close (#1860)"}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1860"}}}</script>
<script type="application/ld+json">{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "37567f93-e2a7-4e2a-ad37-a9160fc62647",
"title": "Save project on file open/close (#1860)",
"sections": [
{
"text": "",
"activityTitle": "**Mark O'Donovan**",
"activityImage": "https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png",
"activitySubtitle": "@shiftee",
"facts": [

]
},
{
"title": "Commit Summary",
"facts": [
{
"name": "5c7c600",
"value": "Save project when opening or closing files"
},
{
"name": "319de78",
"value": "Don't try to save project if none is open"
}
]
},
{
"title": "File Changes",
"facts": [
{
"name": "Modified",
"value": "[src/document.c](https://github.com/geany/geany/pull/1860/files#diff-0) (17 changes)"
}
]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"geany/geany\",\n\"issueId\": 1860,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close pull request",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"PullRequestClose\",\n\"repositoryFullName\": \"geany/geany\",\n\"pullRequestId\": 1860\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/geany/geany/pull/1860"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/geany/geany/pull/1860.patch"
}
],
"@type": "OpenUri",
"name": "View patch"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/geany/geany/pull/1860.diff"
}
],
"@type": "OpenUri",
"name": "View diff"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 338353957\n}"
}
],
"themeColor": "26292E"
}</script>