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