( command: IOpenFileCommand )
| 22 | } |
| 23 | |
| 24 | export function buildOpenFileOptions( |
| 25 | command: IOpenFileCommand |
| 26 | ): OpenFileOptions { |
| 27 | const focus = command.focus ?? true; |
| 28 | |
| 29 | if (command.location) { |
| 30 | switch (command.location) { |
| 31 | case "reuse": |
| 32 | return createOpenFileOptions("reuse", focus); |
| 33 | case "tab": |
| 34 | return createOpenFileOptions("tab", focus); |
| 35 | case "split": { |
| 36 | return createOpenFileOptions( |
| 37 | "split", |
| 38 | focus, |
| 39 | getSplitDirection(command.direction, "vertical") |
| 40 | ); |
| 41 | } |
| 42 | case "window": |
| 43 | return createOpenFileOptions("window", focus); |
| 44 | case "left-sidebar": |
| 45 | return createOpenFileOptions("left-sidebar", focus); |
| 46 | case "right-sidebar": |
| 47 | return createOpenFileOptions("right-sidebar", focus); |
| 48 | default: |
| 49 | break; // fall back to legacy fields |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | const openInNewTab = command.openInNewTab ?? false; |
| 54 | const legacyDirection = getSplitDirection(command.direction); |
| 55 | |
| 56 | // Legacy mapping (pre-location field): |
| 57 | // openInNewTab === false -> reuse the current tab |
| 58 | // openInNewTab === true without direction -> split (default vertical) |
| 59 | if (!openInNewTab) { |
| 60 | return createOpenFileOptions("reuse", focus); |
| 61 | } |
| 62 | |
| 63 | return createOpenFileOptions("split", focus, legacyDirection ?? "vertical"); |
| 64 | } |
no test coverage detected