sublime_text icon indicating copy to clipboard operation
sublime_text copied to clipboard

alt+q wrap_lines missing space before (, [ and {

Open math2001 opened this issue 1 year ago • 3 comments

Description of the bug

alt+q wrap_lines removes spaces before (, { and [, but I don't think it should. Personally, I always want to keep the space.

Steps to reproduce

ctrl+n, open the console and paste

view.settings().set('wrap_width', 80)

Then paste in the buffer

Lorem ipsum dolor sit amet, consectetur adipisicing elit
(quis

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eisumod (commodo

And press alt+q for each paragraph.

Expected behavior

Lorem ipsum dolor sit amet, consectetur adipisicing elit (quis

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eisumod
(commodo

Actual behavior

Lorem ipsum dolor sit amet, consectetur adipisicing elit(quis

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eisumod(commodo

Sublime Text build number

4169

Operating system & version

Ubuntu 22.04

(Linux) Desktop environment and/or window manager

Gnome

Additional information

No response

OpenGL context information

No response

math2001 avatar Apr 28 '24 05:04 math2001

It probably shouldn't in text scope, but in source it might be possible the parentheses defining a function argument list, which most likely is not separated with space from function name.

void
func_name
(int arg1, int arg2)
{ return arg1 + arg2; }

is most likely expected to become

void func_name(int arg1, int arg2) { return arg1 + arg2; }

Space in front of { should however be preserved, ideally.

So whether whitespace should be removed or not may not be simple to answer.

deathaxe avatar May 05 '24 18:05 deathaxe

is alt+Q meant to be used on source code though?

math2001 avatar Jun 21 '24 05:06 math2001

Sure.

deathaxe avatar Jun 21 '24 06:06 deathaxe

related report: https://forum.sublimetext.com/t/inhibit-removing-spaces-before-parentheses-when-wrapping-comments/73233

I have to set ruler to 78 instead of 80 with ST4180, but I can reproduce it. Space in front of column is removed, even though the whole line is not wrapped.

That kind of behavior is certainly a bug.

  1. Set syntax to C++
  2. Paste content from "before" block
  3. Set ruler to 78
  4. Hit alt+q

Before:

// The instruction buffer is a shift register with three 16-bit entries:
//
// * 2x 16-bit entries form the 32-bit current instruction register (CIR) which
//   is the processor's decode window
//

After

// The instruction buffer is a shift register with three 16-bit entries:
//
// * 2x 16-bit entries form the 32-bit current instruction register(CIR) which
//   is the processor's decode window
//

deathaxe avatar Aug 20 '24 18:08 deathaxe