File size: 967 Bytes
4e7644b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * Module-scoped record of the most recent copy-from-editor action.
 *
 * Cmd/Ctrl+C in the Coding-mode editor writes plain text to the system
 * clipboard (default Monaco behavior) and ALSO stashes the copied text
 * + source coordinates here. The Chat composer's paste handler reads
 * this back: if the pasted text matches `text` exactly, the textarea
 * receives the formatted `path:line[-line]` (plus optional fenced code)
 * version instead of the raw text — so pastes outside Chat stay plain
 * but Chat-bound pastes carry editor context.
 */
export interface LastEditorCopy {
  text: string;
  formatted: string;
  // Wall-clock ms; consumers may ignore stale entries.
  ts: number;
}

let last: LastEditorCopy | null = null;

export function setLastEditorCopy(entry: LastEditorCopy): void {
  last = entry;
}

export function getLastEditorCopy(): LastEditorCopy | null {
  return last;
}

export function clearLastEditorCopy(): void {
  last = null;
}