Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • K KTextEditor
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Bugzilla
    • Bugzilla
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FrameworksFrameworks
  • KTextEditor
  • Merge requests
  • !70

Correct an indentation bug.

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Francis Laniel requested to merge eiffel/ktexteditor:cstyle-indent into master Jan 15, 2021
  • Overview 18
  • Commits 1
  • Pipelines 0
  • Changes 6

Hi.

First, I hope you are fine and the same for your relatives.

In this patch, I modified the cstyle.js so keyword block with one statement are now correctly indented when pasting with "Adjust indentation of code pasted from the clipboard" set. Before this patch, the following snippet:

if (condition)
	i++;
return i;

Was indented to:

if (condition)
	i++;
	return i;

I made a gif to show the problem: bug Now, the result is:

if (condition)
	i++;
return i;

As shown by this gif: ok

To confirm the above result, I tested with this file. Without the patch, there is a diff after pasting:

me@home$ diff string.h paste.h
124c124
<               __kernel_size_t n)
---
>                                                        __kernel_size_t n)
142,144c142,144
<       BUILD_BUG_ON_MSG(!__same_type(*(a), *(b)),              \
<                        "type mismatch in memcat_p()");        \
<       (typeof(*a) *)__memcat_p((void **)(a), (void **)(b));   \
---
> BUILD_BUG_ON_MSG(!__same_type(*(a), *(b)),            \
> "type mismatch in memcat_p()");       \
> (typeof(*a) *)__memcat_p((void **)(a), (void **)(b)); \
212c212
<                                      const void *from, size_t available);
---
>                                                                          const void *from, size_t available);
301c301
<       return __underlying_strncpy(p, q, size);
---
>               return __underlying_strncpy(p, q, size);
311c311
<       return p;
---
>               return p;
318c318
<
---
>
321c321
<           (__builtin_constant_p(p[p_size - 1]) && p[p_size - 1] == '\0'))
---
>               (__builtin_constant_p(p[p_size - 1]) && p[p_size - 1] == '\0'))
326c326
<       return ret;
---
>               return ret;
336c336
<       return ret;
---
>               return ret;
355c355
<               __underlying_memcpy(p, q, len);
---
>                       __underlying_memcpy(p, q, len);
369c369
<
---
>
373c373
<
---
>
380c380
<
---
>
392c392
<
---
>
399,405c399,405
<
<       /*
<        * We can now safely call vanilla strscpy because we are protected from:
<        * 1. Read overflow thanks to call to strnlen().
<        * 2. Write overflow thanks to above ifs.
<        */
<       return __real_strscpy(p, q, len);
---
>
>               /*
>                * We can now safely call vanilla strscpy because we are protected from:
>                * 1. Read overflow thanks to call to strnlen().
>                * 2. Write overflow thanks to above ifs.
>                */
>               return __real_strscpy(p, q, len);
420c420
<       __underlying_memcpy(p + p_len, q, copy_len);
---
>               __underlying_memcpy(p + p_len, q, copy_len);
432c432
<       return __underlying_memset(p, c, size);
---
>               return __underlying_memset(p, c, size);
447c447
<       return __underlying_memcpy(p, q, size);
---
>               return __underlying_memcpy(p, q, size);
462c462
<       return __underlying_memmove(p, q, size);
---
>               return __underlying_memmove(p, q, size);
473c473
<       return __real_memscan(p, c, size);
---
>               return __real_memscan(p, c, size);
488c488
<       return __underlying_memcmp(p, q, size);
---
>               return __underlying_memcmp(p, q, size);
498c498
<       return __underlying_memchr(p, c, size);
---
>               return __underlying_memchr(p, c, size);
509c509
<       return __real_memchr_inv(p, c, size);
---
>               return __real_memchr_inv(p, c, size);
520c520
<       return __real_kmemdup(p, size, gfp);
---
>               return __real_kmemdup(p, size, gfp);
535c535
<       memcpy(p, q, size);
---
>               memcpy(p, q, size);
561c561
<                                 const void *src, size_t count, int pad)
---
>                                                                 const void *src, size_t count, int pad)

While with it, there are still differences but none are related to statement after if:

me@home$ diff string.h paste.h
124c124
<               __kernel_size_t n)
---
>                                                        __kernel_size_t n)
142,144c142,144
<       BUILD_BUG_ON_MSG(!__same_type(*(a), *(b)),              \
<                        "type mismatch in memcat_p()");        \
<       (typeof(*a) *)__memcat_p((void **)(a), (void **)(b));   \
---
> BUILD_BUG_ON_MSG(!__same_type(*(a), *(b)),            \
> "type mismatch in memcat_p()");       \
> (typeof(*a) *)__memcat_p((void **)(a), (void **)(b)); \
212c212
<                                      const void *from, size_t available);
---
>                                                                          const void *from, size_t available);
318c318
<
---
>
321c321
<           (__builtin_constant_p(p[p_size - 1]) && p[p_size - 1] == '\0'))
---
>               (__builtin_constant_p(p[p_size - 1]) && p[p_size - 1] == '\0'))
369c369
<
---
>
373c373
<
---
>
380c380
<
---
>
392c392
<
---
>
399c399
<
---
>
561c561
<                                 const void *src, size_t count, int pad)
---
>                                                                 const void *src, size_t count, int pad)

Unfortunately, string.h contains only single statement if and not other keyword block...

I also ran the ctest for ktexteditor and 3 tests failed with and without the patch:

me@home$
The following tests FAILED:
         49 - kateview_test (Failed)
         52 - inlinenote_test (Failed)
         55 - katefoldingtest (Failed)

I think I lack some packages for this test and this is why they failed.

If you have any comments, feel free to share so I can improve this merge request.

Best regards.

Edited Jan 18, 2021 by Francis Laniel
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: cstyle-indent