Skip to content

feat: Cursor Placement Setting & Behavior When Bookmarking#876

Open
metal-gabe wants to merge 12 commits into
alefragnani:masterfrom
metal-gabe:cursor-placement-setting
Open

feat: Cursor Placement Setting & Behavior When Bookmarking#876
metal-gabe wants to merge 12 commits into
alefragnani:masterfrom
metal-gabe:cursor-placement-setting

Conversation

@metal-gabe
Copy link
Copy Markdown

@metal-gabe metal-gabe commented Apr 2, 2026

Add bookmarks.cursorPosition setting

Introduces a new configuration setting, bookmarks.cursorPosition, that controls which column position is stored when a bookmark is created.

New setting: bookmarks.cursorPosition

Value Behavior
currentPosition (default) Stores the cursor's current column position (existing behavior)
lineStart Always stores column 0 (the very start of the line)
contentStart Stores the column of the first non-whitespace character on the line
contentEnd Stores the column just after the last non-whitespace character on the line

Changes

  • package.json — Registers the new bookmarks.cursorPosition configuration contribution with its enum values and descriptions.
  • package.nls.json — Adds localization keys for the new setting's description and all enum option descriptions.
  • src/core/controller.ts — Adds a resolveColumn private method that reads the setting and computes the appropriate column value at bookmark creation time. Both labeled and unlabeled bookmark paths now use resolveColumn instead of position.character directly. The method opens the text document to inspect line content when needed, with a fallback to the active editor.

Note

Copy link
Copy Markdown
Owner

@alefragnani alefragnani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @metal-gabe ,

As discussed in the issue, I would take a different approach. So, the changes in controller could be reverted. You should take a closer look at revealPosition in src/utils/reveal.ts file (since it handles all navigation);list in src/extension.ts and listBookmarks in src/core/operations.ts since it is used by Command Palette and Side Bar to display the bookmarks and their previews.

Let'me know if you need any help

Comment thread .vscode/bookmarks.json Outdated
Comment thread README.md Outdated
Comment thread package.json Outdated
"%bookmarks.configuration.confirmClear.enumDescriptions.sideBar%"
]
},
"bookmarks.cursorPosition": {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in the issue, I would take a different approach. And the settings would have a slight different id/options too.

bookmarks.navigation.columnMode

  • "stored" (default) — current behavior, cursor lands at stored column
  • "lineStart" — always go to column 0
  • "firstNonWhitespace" — go to first non-whitespace character
  • "lineEnd" — go to end of line

Copy link
Copy Markdown
Author

@metal-gabe metal-gabe Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alefragnani alright, the feature has been updated with this new approach

please let me know how everything looks!

@alefragnani alefragnani added enhancement PR needs update The PR needs review by the author labels Apr 3, 2026
@alefragnani alefragnani added this to the Backlog milestone Apr 3, 2026
Copy link
Copy Markdown
Owner

@alefragnani alefragnani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @metal-gabe ,

First of all, sorry for the late reply, and thanks for the update in the PR.

I was able to test it, and it seems to be almost perfect. I noticed two small issues, and would like you to address it.

  • 1. Behavior regression in cursor restore flow: Since revelPosition now always rewrites the target column via navigation.columnMode, when the user cancels the quick-picks from Bookmarks: List and Bookmarks: List from All Files commands, the cursor does not return to the original position, but instead, goes to the position defined in the bookmarks.navigation.columnMode setting. I would suggest adding an optional param to revealPosition function that when set, jump reveal the exact location. Something like:
export function revealPosition(line: number, column: number, directJump?: boolean): void {
    if (isNaN(column)) {
        revealLine(line);
    } else {
        const resolvedColumn = directJump ? column : resolveNavigationColumn(line, column);
        ...

And, in extension.ts on both list() and listFromAllFiles() functions, when selection === undefined, the revealPosition should use directJump as true.

  • 2. Localization missed for other languages: The new entries in package.json should be added to other (than english) languages as well.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement PR needs update The PR needs review by the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] - Cursor Placement Setting & Behavior When Bookmarking

2 participants