mirror of
https://github.com/jasonwilliams/vscode-helix.git
synced 2024-11-09 13:23:38 +03:00
Fail gracefully when trying to jump to a weird document (like a search editor)
Fixes #6445
This commit is contained in:
parent
8fb76a106b
commit
35faa9209b
@ -14,6 +14,7 @@ export enum ErrorCode {
|
||||
NoPreviousRegularExpression = 35,
|
||||
NoWriteSinceLastChange = 37,
|
||||
ErrorWritingToFile = 208,
|
||||
FileNoLongerAvailable = 211,
|
||||
RecursiveMapping = 223,
|
||||
NoStringUnderCursor = 348,
|
||||
NothingInRegister = 353,
|
||||
@ -48,6 +49,7 @@ export const ErrorMessage: IErrorMessage = {
|
||||
35: 'No previous regular expression',
|
||||
37: 'No write since last change (add ! to override)',
|
||||
208: 'Error writing to file',
|
||||
211: 'File no longer available', // TODO: Should be `File "[file_name]" no longer available`
|
||||
223: 'Recursive mapping',
|
||||
348: 'No string under cursor',
|
||||
353: 'Nothing in register',
|
||||
|
@ -6,6 +6,7 @@ import { VimState } from '../state/vimState';
|
||||
import { Jump } from './jump';
|
||||
import { existsAsync } from 'platform/fs';
|
||||
import { Position } from 'vscode';
|
||||
import { ErrorCode, VimError } from '../error';
|
||||
|
||||
const MAX_JUMPS = 100;
|
||||
|
||||
@ -111,8 +112,13 @@ export class JumpTracker {
|
||||
this.isJumpingThroughHistory = true;
|
||||
|
||||
if (jump.document) {
|
||||
// Open jump file from stored editor
|
||||
await vscode.window.showTextDocument(jump.document);
|
||||
try {
|
||||
// Open jump file from stored editor
|
||||
await vscode.window.showTextDocument(jump.document);
|
||||
} catch (e: unknown) {
|
||||
// This can happen when the document we'd like to jump to is weird (like a search editor) or has been deleted
|
||||
throw VimError.fromCode(ErrorCode.FileNoLongerAvailable);
|
||||
}
|
||||
} else if (await existsAsync(jump.fileName)) {
|
||||
// Open jump file from disk
|
||||
await new FileCommand({
|
||||
|
Loading…
Reference in New Issue
Block a user