feat: add file renaming #63
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've added support for renaming files. A tab can be double clicked to edit the name.
The first file cannot be renamed via the UI. This check is using
i > 0
, the same as the delete X. Arguably it would be better to check themainFile
in the store explicitly, but I tried to stay consistent with the existing logic for the X.The
renameFile
logic in the store does support renaming themainFile
, even though that can't be achieved via the UI. It also protects against a couple of error cases that the UI prevents. I thought they might be useful to anyone trying to userenameFile
directly, rather than going through the UI.The files are ordered based on the iteration order of an object. This needed to be taken into account in the renaming logic, to avoid the renamed file jumping to the end.
The SFC filename is included in the compiled output, so it needs to be compiled when the name changes.
The template for
FileSelector.vue
hasn't changed as much as the diff might suggest. A lot of those lines haven't changed apart from the extra indentation caused by the addition of the<template>
tag.