Mapped files
- Dominant language
- JavaScript
- Stars
- 2
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
I think this is going to be the most interesting feature of shide. The idea is pretty simple: you create a file that contains parts of other files. You can edit this composite file, and the original files will update.
For example, you could have a shide command that lets you enter a redux action name, and then creates and opens a mapped file containing the action creator, parts of reducers that use it, and the mapDispatch functions that use the action creator.
This pattern allows you to transcend the concept of files, in that you can create many views on parts of your project.
The implementation is pretty simple.
Say we have these two files:
a.js
```js
var a = 1;
var b = 2;
```
b.js
```js
var c = 3;
var d = 4;
```
And we want to create a mapped file containing the first line of each of these files.
To trade some issues for other issues, we take a snapshot of these files. We'll use a random id for the name of this file. We'll also have a random id for each chunk. For this example, the mapping id is a number, and each chunk has an id that's random letters.
The user doesn't care about this file, it's purely for the implementation.
shide-mapped-14098515.files.js
```js
// SHIDE MAPPED FILE START xbunsvilwoal src/a.js
var a = 1;
var b = 2;
// SHIDE MAPPED FILE END xbunsvilwoal src/a.js
// SHIDE MAPPED FILE START rbmxtadqvftv src/b.js
var c = 3;
var d = 4;
// SHIDE MAPPED FILE END rbmxtadqvftv src/b.js
```
Then we have the actual file the user edits. We've assigned a .js file extension to make the editor happy, but it's unclear how to handle this best if there are multiple file types.
The 1-1 at the end indicates which lines are mapped, lines 1 through 1.
shide-mapped-14098515.working.js
```js
// SHIDE MAPPED START xbunsvilwoal for src/a.js lines 1-1
var a = 1;
// SHIDE MAPPED END xbunsvilwoal for src/a.js
// SHIDE MAPPED START rbmxtadqvftv for src/b.js lines 1-1
var c = 3;
// SHIDE MAPPED END rbmxtadqvftv for src/b.js
```
Say they add a console.log to the first segment, and then save the file.
```js
// SHIDE MAPPED FILE START xbunsvilwoal src/a.js 1-1
var a = 1;
console.log('a is ' + a);
// SHIDE MAPPED FILE END xbunsvilwoal src/a.js
// SHIDE MAPPED FILE START rbmxtadqvftv src/b.js 1-1
var c = 3;
// SHIDE MAPPED FILE END rbmxtadqvftv src/b.js
```
We take the first file we created and and read the content for a.js, which still looks like this:
```js
var a = 1;
var b = 2;
```
Then the file the user edited has the range 1-1 for that a.js, so we take the content between the start end end blocks in the file they edited, and replace lines 1-1 with that content. Finally, we save the updated file to src/a.js, and the user carries on editing.
a.js
```js
var a = 1;
console.log('a is ' + a);
var b = 2;
```
When they close the mapped file, we erase both of the files we created.
---
The primary concern I have with this is that they can have the mapped file open, and the actual a.js file open in another tab. This could cause loss of changes if they open both, edit src/a.js, and then edit the mapped file. I think in some way we need two way sync, where saving the real file causes us to regenerate the mapping file.
Contributor guide
No contributing guide indexed for this repository
Research direction
No source files, tests, or concrete entry points are named. Start by inspecting the shide CLI and its IDE integration structure, then determine how mapped and working files would be represented and synchronized. Done requires a defined implementation scope that addresses editing, saving, cleanup, and conflicting changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100