Improve workspace navigation, search, and tab actions
This commit is contained in:
@@ -71,7 +71,7 @@ export class Documents {
|
||||
}
|
||||
if (!this.disposed && request === this.selection) {
|
||||
// Replace only after a successful read, and never discard edits or disk conflicts.
|
||||
if (!alreadyOpen && previous && previous.contents === previous.saved
|
||||
if (!alreadyOpen && previous && !previous.pinned && previous.contents === previous.saved
|
||||
&& previous.diskContents === undefined && !previous.diskError) {
|
||||
const index = this.buffers.indexOf(previous);
|
||||
const opened = this.buffers.find(b => b.relPath === entry.rel_path);
|
||||
@@ -102,6 +102,25 @@ export class Documents {
|
||||
this.emit();
|
||||
}
|
||||
|
||||
togglePin(path: string) {
|
||||
if (this.disposed) return;
|
||||
const buffer = this.buffers.find(b => b.relPath === path);
|
||||
if (!buffer) return;
|
||||
buffer.pinned = !buffer.pinned;
|
||||
this.emit();
|
||||
}
|
||||
|
||||
move(path: string, to: number) {
|
||||
if (this.disposed || !Number.isInteger(to)) return;
|
||||
const from = this.buffers.findIndex(b => b.relPath === path);
|
||||
if (from < 0) return;
|
||||
const index = Math.max(0, Math.min(to, this.buffers.length - 1));
|
||||
if (from === index) return;
|
||||
const [buffer] = this.buffers.splice(from, 1);
|
||||
this.buffers.splice(index, 0, buffer);
|
||||
this.emit();
|
||||
}
|
||||
|
||||
rename(from: string, to: string) {
|
||||
for (const b of this.buffers) {
|
||||
if (b.kind === "empty") continue;
|
||||
|
||||
Reference in New Issue
Block a user