improved diffing algorithm

This commit is contained in:
Chris Kruining 2024-10-30 16:27:34 +01:00
parent 6d1e011621
commit 0501a0a463
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
6 changed files with 156 additions and 19 deletions

View file

@ -79,6 +79,8 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
return mutations.map(m => {
const [key, lang] = splitAt(m.key, m.key.lastIndexOf('.'));
console.log(m.key, key, lang, entries);
return { ...m, key, file: entries.get(key)?.[lang] };
});
}));
@ -195,10 +197,12 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
remove(Object.keys(selection()));
}, { key: 'delete', modifier: Modifier.None }),
inserNewKey: createCommand('insert new key', () => {
api()?.insert('this.is.some.key');
}),
inserNewLanguage: noop.withLabel('insert new language'),
} as const;
const commandCtx = useCommands();
return <div class={css.root}>
<Command.Add commands={[commands.saveAs, commands.closeTab]} />
@ -218,9 +222,9 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
</Menu.Item>
<Menu.Item label="edit">
<Menu.Item command={noop.withLabel('insert new key')} />
<Menu.Item command={commands.inserNewKey} />
<Menu.Item command={noop.withLabel('insert new language')} />
<Menu.Item command={commands.inserNewLanguage} />
<Menu.Separator />