Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • TortoiseGit TortoiseGit
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 382
    • Issues 382
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 16
    • Merge requests 16
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • TortoiseGitTortoiseGit
  • TortoiseGitTortoiseGit
  • Issues
  • #3449
Closed
Open
Issue created Nov 05, 2019 by Stein Somers@ssomers

Crash when indenting short lines (pressing tab key)

What steps will reproduce the problem?

  1. Compare two empty files
  2. Enter two lines with text "a" and "b" in the right panel
  3. Select both lines
  4. Press tab

What is the expected output? What do you see instead?

Expect indenting to happen, like when happens if the selected text is already indented. Instead, crashes and sends error report.

What version of TortoiseGit and Git are you using? On what operating system?

2.9.0.0 and latest master.

Please provide any additional information below.

So I built and debugged the code. The crash happens in CBaseView::GetIndentCharsForLine in the (m_nTabMode & TABMODE_SMARTINDENT) part because GetViewLine(i) does not take kindly to a negative index.

I'd like to fix it but I'm mystified about the code:

  • line.GetLength() > m_nTabSize: if it counted the number of leading spaces, I would understand. But just length, how is that a hint that spaces are wanted? Anyway, the fact that lines usually are longer is the reason indentation usually doesn't crash.
  • bool above = i > 0... and not >= 0 while clearly y = 0 and GetViewLine(y) returns the first line. So if there's a tab on the line above, we want to insert tabs, but not if that line is the first line??
  • nTabMode = 1 (meaning spaces) if both the nth line above and nth line below are longer than tab size. Even if I understood that rule, why not if the 1st line above is longer, the 1st line below is not, but the 2nd line below is longer?
Edited Nov 05, 2019 by Stein Somers
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking