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

ko/editor.setSelection works incorrectly with tabs #2123

Closed
Defman21 opened this Issue Nov 1, 2016 · 11 comments

Comments

Projects
None yet
4 participants
@Defman21
Contributor

Defman21 commented Nov 1, 2016

Short Summary

Steps to Reproduce

<p>
[tab width = 2]
[tab width = 2]p@cursor;
</p>

Run

e = editor.getCursorPosition();
e.ch -= 1;
e.absolute -= 1;
editor.setSelection(editor.getCursorPosition(), e);

Expected results

p selected

Actual results

some space after p selected.

Platform Information

Komodo Edit or IDE? IDE/Edit
Komodo Version? 10.1.1
Operating System (and version)? -

Additional Information

<p>
[tab width = 2]
@cursor;[tab width = 2]p
</p>
editor.getCursorPosition(); -> Object {line: 2, ch: 0, absolute: 50}

---
<p>
[tab width = 2]
[tab width = 2]@cursor;p
</p>
editor.getCursorPosition(); -> Object {line: 2, ch: 2, absolute: 51}

---
<p>
[tab width = 2]
[tab width = 2]p@cursor;
</p>
editor.getCursorPosition(); -> Object {line: 2, ch: 3, absolute: 52}
@cgchoffman

This comment has been minimized.

Member

cgchoffman commented Nov 1, 2016

Looks like tabs are interpreted as single characters. I don't understand your test data though @Defman21, in your examples they are all on line 3, not 2, and there are def no 50 chars to get a abs pos of 50, unless you tested with [tab width = 2] literally in the file?

@cgchoffman

This comment has been minimized.

Member

cgchoffman commented Nov 1, 2016

To clarify, confirmed this. When you use Tab instead of spaces, set selection breaks as tabs are interpreted as single chars.

@cgchoffman

This comment has been minimized.

Member

cgchoffman commented Nov 1, 2016

Assigning to @mitchell-as for now as I don't know who to properly deal with tabs vs. spaces.

@Defman21

This comment has been minimized.

Contributor

Defman21 commented Nov 1, 2016

I don't understand your test data though @Defman21, in your examples they are all on line 3, not 2, and there are def no 50 chars to get a abs pos of 50, unless you tested with [tab width = 2] literally in the file?

Oops. My bad.

@Defman21

This comment has been minimized.

Contributor

Defman21 commented Nov 1, 2016

Defman21 added a commit to Defman21/Xemmet that referenced this issue Nov 1, 2016

fixed #4
editor.scimoz().setSel should be reverted once Komodo/KomodoEdit#2123 is fixed
@Defman21

This comment has been minimized.

Contributor

Defman21 commented Nov 1, 2016

At least it works in Xemmet :)

@cgchoffman

This comment has been minimized.

Member

cgchoffman commented Nov 1, 2016

looks like there should be used pos.absolute without any math.

Scintilla (aka, scimoz) uses line numbers starting at 0. But the line numbers output to users from this Editor SDK start at 1. Since that is being passed to a scimoz function that decremented is correct. That's unrelated to the bug.

The bug is that tab chars are seen as a single char rather than the number of spaces they take up in the document.

At least it works in Xemmet :)

Can you clarify? Are you saying the bug reported here is not reproducible when using Xemmet?

@Defman21

This comment has been minimized.

Contributor

Defman21 commented Nov 1, 2016

It works if I select using scimoz.setSel(pos.absolute, ...)

https://github.com/Defman21/Xemmet/blob/master/content/xemmet.js#L486

Xemmet does not override any Komodo functions.

@Defman21

This comment has been minimized.

Contributor

Defman21 commented Nov 1, 2016

In which version the fix will arrive?

@mitchell-as

This comment has been minimized.

Member

mitchell-as commented Nov 1, 2016

@cgchoffman tabs are supposed to only count as one character, never more.

@Defman21 The next one.

@Defman21

This comment has been minimized.

Contributor

Defman21 commented Nov 1, 2016

10.1.2?

@Naatan Naatan added this to the 10.1.2 milestone Nov 2, 2016

Naatan added a commit that referenced this issue Nov 8, 2016

fix: sdk: editor: Calculate absolute positions based on line/col prop…
…erly - fixes #2123

rn=

(integrated from the KomodoIDE master branch change 8043ff1 by Mitchell <mitchellb@activestate.com>)

Komodo/KomodoIDE@8043ff1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment