| 1 | import { SetCodeToEditPayload } from "core"; |
| 2 | import { getUriPathBasename } from "core/util/uri"; |
| 3 | |
| 4 | export function getEditFilenameAndRangeText(code: SetCodeToEditPayload) { |
| 5 | const fileName = getUriPathBasename(code.filepath); |
| 6 | let title = `${fileName}`; |
| 7 | |
| 8 | if ("range" in code) { |
| 9 | const start = code.range.start.line + 1; |
| 10 | const end = code.range.end.line + 1; |
| 11 | const isInsertion = start === end; |
| 12 | title += isInsertion |
| 13 | ? ` - Inserting at line ${start}` |
| 14 | : ` (${start} - ${end})`; |
| 15 | } |
| 16 | |
| 17 | return title; |
| 18 | } |