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

[BUG] Formatting operation removes spaces around operator, making code invalid #679

Open
galtm opened this issue Apr 22, 2024 · 2 comments

Comments

@galtm
Copy link

galtm commented Apr 22, 2024

Describe the bug
When I use XQuery > Format code on a certain function, some spaces get removed such that the code is no longer valid. The problem might be related to a code comment near the code that becomes invalid.

Expected behavior
The code should be formatted differently but should still produce the same behavior.

To Reproduce

  1. Enter this code in eXide:
xquery version "3.1";

declare function local:myfcn(
  $arg as xs:integer
  ) as xs:string* {
  
  (:
    Multiple-line comment that is
    not in eXist-db style
  :)
  if ($arg gt 0)
  then 'positive'
  else 'nonpositive'
};

local:myfcn(1)
  1. Select all the text (or only the function declaration)
  2. Select XQuery > Format code

The function declaration now looks like this, with no spaces around the gt operator:

declare function local:myfcn($arg as xs:integer)
as xs:string*
{
    (:
     : Multiple-line comment that is
     : not in eXist-db style
     :)if($arggt0)then'positive'else'nonpositive'};

Screenshot
image

Context (please always complete the following information):

  • OS: Windows 10
  • eXist-db Version: 6.2.0
  • Java Version:
openjdk version "11.0.16" 2022-07-19 LTS
OpenJDK Runtime Environment Microsoft-38106 (build 11.0.16+8-LTS)
OpenJDK 64-Bit Server VM Microsoft-38106 (build 11.0.16+8-LTS, mixed mode)
  • App Version: 3.5.0

Additional context

@joewiz
Copy link
Member

joewiz commented Apr 22, 2024

@galtm Thank you for the report! This sounds like a bug indeed. It is likely in the upstream project that @wolfgangmm drew on when he contributed the feature. That project, xqlint, has since changed its architecture in a way that makes it incompatible with eXide. Thus, I am not hopeful that a fix will be easy. (I, at least, lack the javascript skills that would be necessary to investigate the bug.) If we confirm the problem is irreparable, the solution may be to remove the feature, lest it cause damage to people's code.

@galtm
Copy link
Author

galtm commented Apr 22, 2024

@joewiz, Thanks for looking at this so quickly and for setting my expectations about the feasibility of a fix.

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

No branches or pull requests

2 participants