Skip to content

Commit

Permalink
🐛 Fix not aborting progress when there are errors (#541)
Browse files Browse the repository at this point in the history
Fix #538.
  • Loading branch information
SPGoding authored Jun 28, 2020
1 parent db524e4 commit 89ba2d3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This project follows the [all-contributors](https://github.com/all-contributors/
<td align="center"><a href="https://www.mcbbs.net/home.php?mod=space&uid=1834567"><img src="https://www.mcbbs.net/uc_server/avatar.php?uid=1834567&size=middle" width="64px;" alt=""/><br /><sub><b>ChapterII</b></sub></a></td><td align="left"><a href="https://github.com/SPGoding/datapack-language-server/issues/467" target="_blank" title="Bug reports">🐛 #467</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/ChenCMD"><img src="https://avatars2.githubusercontent.com/u/46134240?s=460&u=ca934b86e5189ea9c598a51358571e777e21aa2f&v=4" width="64px;" alt=""/><br /><sub><b>ChenCMD</b></sub></a></td><td align="left"><a href="https://github.com/SPGoding/datapack-language-server/issues/402" target="_blank" title="Ideas, Planning, and Feedback">✨ #402</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/458" target="_blank" title="Bug reports">🐛 #458</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/487" target="_blank" title="Bug reports">🐛 #487</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/515" target="_blank" title="Bug reports">🐛 #515</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/516" target="_blank" title="Bug reports">🐛 #516</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/517" target="_blank" title="Bug reports">🐛 #517</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/519" target="_blank" title="Bug reports">🐛 #519</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/520" target="_blank" title="Bug reports">🐛 #520</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/529" target="_blank" title="Bug reports">🐛 #529</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/530" target="_blank" title="Bug reports">🐛 #530</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/536" target="_blank" title="Bug reports">🐛 #536</a></td>
<td align="center"><a href="https://github.com/ChenCMD"><img src="https://avatars2.githubusercontent.com/u/46134240?s=460&u=ca934b86e5189ea9c598a51358571e777e21aa2f&v=4" width="64px;" alt=""/><br /><sub><b>ChenCMD</b></sub></a></td><td align="left"><a href="https://github.com/SPGoding/datapack-language-server/issues/402" target="_blank" title="Ideas, Planning, and Feedback">✨ #402</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/458" target="_blank" title="Bug reports">🐛 #458</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/487" target="_blank" title="Bug reports">🐛 #487</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/515" target="_blank" title="Bug reports">🐛 #515</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/516" target="_blank" title="Bug reports">🐛 #516</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/517" target="_blank" title="Bug reports">🐛 #517</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/519" target="_blank" title="Bug reports">🐛 #519</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/520" target="_blank" title="Bug reports">🐛 #520</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/529" target="_blank" title="Bug reports">🐛 #529</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/530" target="_blank" title="Bug reports">🐛 #530</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/536" target="_blank" title="Bug reports">🐛 #536</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/538" target="_blank" title="Bug reports">🐛 #538</a></td>
<td align="center"><a href="https://afdian.net/u/da477488928011ea8ea552540025c377"><img src="https://pic1.afdiancdn.com/default/avatar/avatar-purple.png?imageView2/1/w/240/h/240" width="64px;" alt=""/><br /><sub><b>ColorRain_Tree</b></sub></a></td><td align="left"><a href="https://github.com/SPGoding/datapack-language-server/blob/master/CONTRIBUTING.md" target="_blank" title="Financial support">💛 <span style="color:gold;">(#°Д°)</span></a></td>
</tr>
<tr>
Expand Down
3 changes: 2 additions & 1 deletion contributors/.all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
{ "type": "bug", "link": "issues/520", "text": "#520" },
{ "type": "bug", "link": "issues/529", "text": "#529" },
{ "type": "bug", "link": "issues/530", "text": "#530" },
{ "type": "bug", "link": "issues/536", "text": "#536" }
{ "type": "bug", "link": "issues/536", "text": "#536" },
{ "type": "bug", "link": "issues/538", "text": "#538" }
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion contributors/2.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A big _thank you_ goes to these wonderful people! (sorted by the Unicode of name
<td align="center"><a href="https://www.mcbbs.net/home.php?mod=space&uid=1834567"><img src="https://www.mcbbs.net/uc_server/avatar.php?uid=1834567&size=middle" width="64px;" alt=""/><br /><sub><b>ChapterII</b></sub></a></td><td align="left"><a href="https://github.com/SPGoding/datapack-language-server/issues/467" target="_blank" title="Bug reports">🐛 #467</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/ChenCMD"><img src="https://avatars2.githubusercontent.com/u/46134240?s=460&u=ca934b86e5189ea9c598a51358571e777e21aa2f&v=4" width="64px;" alt=""/><br /><sub><b>ChenCMD</b></sub></a></td><td align="left"><a href="https://github.com/SPGoding/datapack-language-server/issues/402" target="_blank" title="Ideas, Planning, and Feedback">✨ #402</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/458" target="_blank" title="Bug reports">🐛 #458</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/487" target="_blank" title="Bug reports">🐛 #487</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/515" target="_blank" title="Bug reports">🐛 #515</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/516" target="_blank" title="Bug reports">🐛 #516</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/517" target="_blank" title="Bug reports">🐛 #517</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/519" target="_blank" title="Bug reports">🐛 #519</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/520" target="_blank" title="Bug reports">🐛 #520</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/529" target="_blank" title="Bug reports">🐛 #529</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/530" target="_blank" title="Bug reports">🐛 #530</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/536" target="_blank" title="Bug reports">🐛 #536</a></td>
<td align="center"><a href="https://github.com/ChenCMD"><img src="https://avatars2.githubusercontent.com/u/46134240?s=460&u=ca934b86e5189ea9c598a51358571e777e21aa2f&v=4" width="64px;" alt=""/><br /><sub><b>ChenCMD</b></sub></a></td><td align="left"><a href="https://github.com/SPGoding/datapack-language-server/issues/402" target="_blank" title="Ideas, Planning, and Feedback">✨ #402</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/458" target="_blank" title="Bug reports">🐛 #458</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/487" target="_blank" title="Bug reports">🐛 #487</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/515" target="_blank" title="Bug reports">🐛 #515</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/516" target="_blank" title="Bug reports">🐛 #516</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/517" target="_blank" title="Bug reports">🐛 #517</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/519" target="_blank" title="Bug reports">🐛 #519</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/520" target="_blank" title="Bug reports">🐛 #520</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/529" target="_blank" title="Bug reports">🐛 #529</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/530" target="_blank" title="Bug reports">🐛 #530</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/536" target="_blank" title="Bug reports">🐛 #536</a><br><a href="https://github.com/SPGoding/datapack-language-server/issues/538" target="_blank" title="Bug reports">🐛 #538</a></td>
<td align="center"><a href="https://afdian.net/u/da477488928011ea8ea552540025c377"><img src="https://pic1.afdiancdn.com/default/avatar/avatar-purple.png?imageView2/1/w/240/h/240" width="64px;" alt=""/><br /><sub><b>ColorRain_Tree</b></sub></a></td><td align="left"><a href="https://github.com/SPGoding/datapack-language-server/blob/master/CONTRIBUTING.md" target="_blank" title="Financial support">💛 <span style="color:gold;">(#°Д°)</span></a></td>
</tr>
<tr>
Expand Down
15 changes: 8 additions & 7 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ connection.onInitialized(() => {
* datapack.regenerateCache - Regenerate cache.
*/
connection.onExecuteCommand(async ({ command, arguments: args }) => {
let progress: WorkDoneProgress | undefined = undefined
try {
switch (command) {
case 'datapack.fixFile': {
Expand All @@ -577,7 +578,7 @@ connection.onInitialized(() => {
break
}
case 'datapack.fixWorkspace': {
const progress = await connection.window.createWorkDoneProgress()
progress = await connection.window.createWorkDoneProgress()
progress.begin(locale('server.fixing-workspace'))
for (const root of roots) {
const dataPath = path.join(root.fsPath, 'data')
Expand All @@ -601,24 +602,24 @@ connection.onInitialized(() => {
})
}
}
progress.done()
break
}
case 'datapack.regenerateCache': {
const progress = await connection.window.createWorkDoneProgress()
progress = await connection.window.createWorkDoneProgress()
progress.begin(locale('server.regenerating-cache'))

cacheFile = clone(DefaultCacheFile)
await updateCacheFile(cacheFile, roots, progress)

progress.done()
break
}
default:
throw new Error(`Unknown ‘workspace/executeCommand’ request for ‘${command}’.`)
}
} catch (e) {
console.error('onExecuteCommand', e)
} finally {
if (progress) {
progress.done()
}
}
})
})
Expand Down Expand Up @@ -678,7 +679,7 @@ async function saveCacheFile() {
}
}

async function gcInfo(uri: Uri ) {
async function gcInfo(uri: Uri) {
const getTheConfig = async () => await fetchConfig(uri)
const getTheCommandTree = async (config: Config) => await getCommandTree(config.env.cmdVersion)
const getTheVanillaData = async (config: Config) => await getVanillaData(config.env.dataVersion, config.env.dataSource, versionInformation, globalStoragePath)
Expand Down

0 comments on commit 89ba2d3

Please sign in to comment.