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

Wrong text alignment & cursor when editing JSON object-valued preferences via phantom button #347

Closed
ratijas opened this issue Jun 10, 2021 · 0 comments · Fixed by #348
Closed
Labels
Milestone

Comments

@ratijas
Copy link
Contributor

ratijas commented Jun 10, 2021

Description

In preferences split editor, inline phantom button with pencil icon in the left pane sometimes misbehaves: when inserting new preferences entry to the right page, it may misalign text and cursor with selection. The bug seem to affect json map (object) values preferences. Note that there aren't any of such objects in the general User/Preferences.sublime-settings, so check out Package Control.sublime-settings instead.

Steps to reproduce

  1. Open menu Preferences > Package Settings > Package Control -> Settings.
  2. Split window should show up with default config on the left and user's prefs on the right.
  3. Click phantom pencil icon on any preference which has JSON object default value on the left, and which is not yet defined on the right.

Before:
1-before

Actual result

After:
2-after

Expected result

Expected to see something similar to what happens with JSON arrays:

  • new preference name on its own line, followed by double-colon,
  • JSON object's curly braces on their own lines below,
  • cursor between braces on its own line, indented.

Like this (cursor is denoted by ${|}):

	"install_prereleases":
	[
		${|}
	],

Version

Operating System: Arch Linux
Kernel Version: 5.12.9-arch1-1
OS Type: 64-bit
Graphics Platform: X11
Sublime Text: Stable, Build 4107

@ratijas ratijas changed the title Wrong text alignment & cursor position after clicking phantom button in references editor Wrong text alignment & cursor when editing JSON object-valued preferences via phantom button Jun 10, 2021
ratijas added a commit to ratijas/PackageDev that referenced this issue Jun 11, 2021
The root cause was that text manipulation was reordered in a wrong way:
JSON-encoded string was converted to snippet-field-content-encoded
string first, but then it was treated as a simply JSON-encoded string
again. Namely, stripping curly brackets away _after_ encoding them
as \\} broke cursor things in a weird ways.

Used pretty printing just because it looks better. But it required extra
whitespace stripping: both outside and inside stripped
brackets/braces.

Also changed variable name from `encoded` to `content` in fmt, so they
can never be accidentally reordered again.

Fixes SublimeText#347
@FichteFoll FichteFoll added this to the 3.3.2 milestone Jun 22, 2021
FichteFoll pushed a commit that referenced this issue Feb 26, 2022
The root cause was that text manipulation was reordered in a wrong way:
JSON-encoded string was converted to snippet-field-content-encoded
string first, but then it was treated as a simply JSON-encoded string
again. Namely, stripping curly brackets away _after_ encoding them
as \\} broke cursor things in a weird ways.

Used pretty printing just because it looks better. But it required extra
whitespace stripping: both outside and inside stripped
brackets/braces.

Also changed variable name from `encoded` to `content` in fmt, so they
can never be accidentally reordered again.

Fixes #347
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants