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

fix textarea newline handle #32966

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

metiftikci
Copy link
Contributor

  • Fix cursor position if input newline on middle of lines
  • Increment number if numbered list

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 23, 2024
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 23, 2024
} else {
// start a new line with the same indention and prefix
let newPrefix = prefix;
// a simple approach, otherwise it needs to parse the lines after the current line
if (/^\d+\./.test(prefix)) newPrefix = `1. ${newPrefix.slice(newPrefix.indexOf('.') + 2)}`;
Copy link
Contributor Author

@metiftikci metiftikci Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what old code does

got it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment above // a simple approach, otherwise it needs to parse the lines after the current line

@techknowlogick techknowlogick added the topic/ui Change the appearance of the Gitea UI label Dec 23, 2024
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 24, 2024

I guess it's not right for this case:

1. a
2. b <---  enter here
3. c

Your result might be

1. a
2. b
3. 
3. c

?

I didn't do that (auto-increase) because it needs a complex algorithm to make it right. And for most cases only using 1. seems clearer and easier when editing, and it doesn't affect the rendering.


I added a new test: testInput({value: '1. a\n2. b\n3. c', pos: 4}, {value: '1. a\n2. \n2. b\n3. c', pos: 8});, there are two 2., not sure whether it is what you want.

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 24, 2024
@metiftikci
Copy link
Contributor Author

@wxiaoguang should i revert the increase number code or try to implement increasing numbers below?

@wxiaoguang
Copy link
Contributor

@wxiaoguang should i revert the increase number code or try to implement increasing numbers below?

Either is fine, but there are many edge cases, even GitHub doesn't get it completely right, and it would be quite complex, maybe at least hundreds lines of code in my mind.

So at the moment, I would prefer to revert "the increase number"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/frontend size/M Denotes a PR that changes 30-99 lines, ignoring generated files. topic/ui Change the appearance of the Gitea UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants