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

Remove ability to get column and replace with getting character count from line start #355

Closed
dsherret opened this issue Jul 3, 2018 · 1 comment

Comments

@dsherret
Copy link
Owner

dsherret commented Jul 3, 2018

Silly mistake, but a column should be 1-indexed. For example:

const sourceFile = project.createSourceFile("test.ts", "");
sourceFile.getColumnAtPos(0); // should be 1 and not 0

This applies to getColumnAtPos, getStartColumn and getEndColumn.

@dsherret dsherret added the bug label Jul 3, 2018
@dsherret
Copy link
Owner Author

dsherret commented Jul 4, 2018

Hmmm... I was looking in visual studio and noticed there's "col" and "ch"... looking it up: https://stackoverflow.com/questions/19226060/what-is-the-col-value-in-visual-studio-text-editor

The difference between column and character positions is evident for characters such as the tab character that can incorporate more than one column

So I have getColumn-like methods implemented completely wrong. I don't think it makes sense to have this function in ts-simple-ast because properly implemented it depends on how the character is displayed (ex. font, character design, tab size).

I'm going to deprecate these methods and replace them with sourceFile.getLengthFromLineStartAtPos(pos); (can't think of a better name atm).

@dsherret dsherret changed the title Getting a column should be 1-indexed Remove ability to get column and replace with getting character count from line start Jul 4, 2018
dsherret added a commit that referenced this issue Jul 4, 2018
@dsherret dsherret closed this as completed Jul 4, 2018
dsherret added a commit that referenced this issue May 14, 2019
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

1 participant