Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #8787 add vim.openFilePosition #8819

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,19 @@
"Replace matched text with substitutions"
]
},
"vim.openFilePosition": {
"type": "string",
"markdownDescription": "use `gf` to open file position by relative or absolute.",
"default": "relative",
"enum": [
"relative",
"absolute"
],
"enumDescriptions": [
"Open file position by relative position.",
"Open file position by absolute position."
]
},
"vim.incsearch": {
"type": "boolean",
"markdownDescription": "Show where a `/` or `?` search matches as you type it.",
Expand Down
4 changes: 3 additions & 1 deletion src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,9 @@ class CommandOpenFile extends BaseCommand {
const workspaceRootPath = vscode.workspace.getWorkspaceFolder(vimState.document.uri)?.uri
.fsPath;
const filePath =
path.isAbsolute(fileInfo[1]) || !workspaceRootPath
configuration.openFilePosition === 'relative' ||
path.isAbsolute(fileInfo[1]) ||
!workspaceRootPath
? fileInfo[1]
: path.join(workspaceRootPath, fileInfo[1]);
const line = parseInt(fileInfo[2], 10);
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ class Configuration implements IConfiguration {

inccommand: '' | 'append' | 'replace' = '';

openFilePosition: 'relative' | 'absolute' = 'relative';

incsearch = true;

startInInsertMode = false;
Expand Down
5 changes: 5 additions & 0 deletions src/configuration/iconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ export interface IConfiguration {
*/
inccommand: '' | 'append' | 'replace';

/**
* Use `gf` to open file position
*/
openFilePosition: 'relative' | 'absolute';

/**
* Show results of / or ? search as user is typing?
*/
Expand Down
1 change: 1 addition & 0 deletions test/testConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class Configuration implements IConfiguration {
history = 50;
incsearch = true;
inccommand = '' as const;
openFilePosition = 'relative' as const;
startInInsertMode = false;
statusBarColorControl = false;
statusBarColors: IModeSpecificStrings<string | string[]> = {
Expand Down
Loading