Skip to content

fix: allow overriding textwidth via :set tw=N - #10098

Open
sferencik wants to merge 1 commit into
VSCodeVim:masterfrom
sferencik:fix-7809-set-textwidth
Open

sferencik wants to merge 1 commit into
VSCodeVim:masterfrom
sferencik:fix-7809-set-textwidth

Conversation

@sferencik

Copy link
Copy Markdown

Fixes the :set tw=N (:set textwidth=N) command.

In PR #7747, vim.textwidth was made language-configurable by turning textwidth into a getter without a setter. As a result, running :set tw=N threw:
TypeError: Cannot set property textwidth of #<Configuration> which has only a getter
(which was caught and logged only to the Vim extension output channel).

Context & Comparison to PR #7811

@adamjhawley previously attempted to fix this in #7811 by calling vscode.workspace.getConfiguration('vim').update('textwidth', ...) in the setter. However, as noted in the discussion there, writing to settings.json on disk whenever someone runs :set tw=N has unwanted side effects: it dirties project repositories and triggers VS Code configuration reload events across extensions.

This PR implements an in-memory override:

  • When :set tw=N is executed, the session override takes precedence in memory without writing to or dirtying settings.json on disk (preserving traditional Vim session semantics).
  • When no override is active, it continues to respect language-specific VS Code settings ([python], [markdown], etc.).
  • Reloading configuration cleanly resets the session override.

Fixes #7809
Supersedes and closes #7811

Adds an in-memory setter and override for `configuration.textwidth`.
When `:set tw=N` is executed, the session override takes precedence.
When no override is active, it continues to fall back to the active
language's VS Code configuration.

Fixes VSCodeVim#7809
Supersedes VSCodeVim#7811
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

set tw=# throws an error

1 participant